Thursday, September 13, 2012

SICP 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.

Interpreter gets stuck in an infinite loop. It will keep trying to evaluate (f f) which involves evaluating (f (f f)) and then (f (f (f f))) &c.

No comments:

Post a Comment