Note: this wiki is now retired and will no longer be updated!

The static final versions of the pages are left as a convenience for readers. Note that meta-pages such as "discussion," "history," etc., will not work.

SICP exercise 1.34

From Drewiki
Jump to: navigation, search

Problem

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

Let's use the substitution model to illustrate:

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

The combination (2 2) is an error, since 2 is neither a primitive nor a compound procedure.

Personal tools