sicp-4-2-3

Posted on 2015-03-12 20:27:03 +0900 in SICP Lisp

4.32

In the current version, car is lazy as well, which makes it possible to build structures such as infinite tree.

4.33

;'(a b c)-->(cons 'a (cons 'b (cons 'c '())))

((quoted? exp) (text-of-quotation exp env))

(define (list->cons lst)
  (if (null? lst)
    '()
    (list 'cons
          (list 'quote (car lst))
          (list->cons (cdr lst)))))

(define (text-of-quotation exp env)
  (let ((quoted-operand (cadr exp)))
    (if (pair? quoted-operand)
      (eval (list->cons quoted-operand) env)
      quoted-operand)))
----------------------------------- 本文内容遵从CC版权协议转载请注明出自kamelzcs -----------------------------------
«  | sicp-4-2-1 »

Hide Comments

comments powered by Disqus