2013年8月29日木曜日

開発環境

計算機プログラムの構造と解釈(Gerald Jay Sussman(原著)、Julie Sussman(原著)、Harold Abelson(原著)、和田 英一(翻訳)、ピアソンエデュケーション、原書: Structure and Interpretation of Computer Programs (MIT Electrical Engineering and Computer Science)(SICP))の4(超言語的抽象)、4.1(超循環評価器)、4.1.2(式の表現)、問題 4.6を解いてみる。

その他参考書籍

問題 4.6

コード(BBEdit)

sample.scm

(define (let? exp) (tagged-list? exp 'let))

(define (let-vars-and-exps exp) (cadr exp))

(define (let-body exp) (cddr exp))

(define (let-parameters exp)
  (map car (let-vars-and-exps exp)))

(define (let-exps exp)
  (map cadr (let-vars-and-exps exp)))

(define (let->combination exp)
  (cons (make-lambda (let-parameters exp)
                     (let-body exp))
        (let-exps exp)))

;; 組み込み
(define (eval exp env)
  (cond ()
        ;; …
        ((cond? exp) (eval (cond->if exp) env))
        ((let? exp) (eval (let->combination exp) env))
        ;; …))

0 コメント:

コメントを投稿