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.
(f f)
_ *** ERROR -- Operator is not a PROCEDURE_
The reasons this happens if clearer once we trace the evaluation steps:
(f f)
(f 2)
(2 2)
Since the leftmost side is not an operator but a number the interpreter doesn’t know what to do and hence gives the error above.