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.
The process of evaluating (f f)
unfolds as follows:
(f f)
(f 2)
(2 2)
;The object 2 is not applicable.
An error occurs as 2 is not a procedure (i.e. “The object 2 is not applicable”) that can be evaluted with the argument 2.