灯下 登录
计算机科学 / SICP / 1.3.2 Constructing Procedures Using Lambda

Exercise 1.34 · 习题

Exercise 1.34: Suppose we define the procedure

(define (f g) (g 2))

Then we have

(f square)
4

(f (lambda (z) (* z (+ z 1))))
6

What happens if we (perversely) ask the interpreter to evaluate the combination

(f f)? Explain.

练习 1.34:假设我们定义过程

(define (f g) (g 2))

那么有

(f square)
4

(f (lambda (z) (* z (+ z 1))))
6

如果我们(出于恶趣味)让解释器对组合式 (f f) 求值,会发生什么?请解释。

Racket #lang sicp
(define (f g) (g 2))
Racket #lang sicp
(f square)
4

(f (lambda (z) (* z (+ z 1))))
6