Exercise 4.28

Here is some code that would cause the evaluator to generate an error if the operand is sent to eval rather than actual-value.

(interpret '(define (square x) (* x x)))
(interpret '(define (halve x) (floor (/ x 2))))
(interpret '(define (combine f g)
  (lambda (n)
    (f (g n)))))
(interpret '((combine halve square) 10))

The reason is that the application (combine halve square) has an operator combine and two operands halve and square, but the operands are both still thunks.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s