Exercise 4.1

From left to right:

1
2
3
4
5
6
(define (list-of-values exps env)
  (if (no-operands? exps)
      nil
      (let ((first (eval (first-operand exps) env)))
        (cons first
              (list-of-values (rest-operands exps) env)))))

From right to left:

1
2
3
4
5
6
(define (list-of-values exps env)
  (if (no-operands? exps)
      nil
      (let ((rest (list-of-values (rest-operands exps) env)))
        (cons (eval (first-operand exps) env)
              rest))))
Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution 2.0 UK: England & Wales License.

Tags: ,

Leave a Reply

CAPTCHA Image

Powered by WP Hashcash

Please wrap all source codes with [code][/code] tags.