SICP - Solution: Exercise 1.34

Oct 27, 2018 04:03 · 72 words · 1 minute read

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.

Solution

The trace for the evaluation of (f f) will be:

(f f)
(f 2)
(2 2)

And will fail, since 2 is not an function that can be applied.