問題4.22 – SICP(計算機プログラムの構造と解釈)その195
2009年06月06日
問題4.22
構文解析手続き analyze に let->combination を使った解析を追加する。
(define (analyze exp) (cond ((self-evaluating? exp) (analyze-self-evaluating exp)) ... ((let? exp) (analyze (let->combination exp))) ((application? exp) (analyze-application exp)) (else (error "Unknown expression type -- ANALYZE" exp)))) (define (let->combination exp) (if (pair? (car (let-clauses exp))) (expand-let-clauses (let-clauses exp)) (expand-named-let-clauses (let-clauses exp))))
実行結果
;;; M-Eval input:
(define (f x)
(let ((double (* x x)))
(+ double 10)))
;;; M-Eval value:
ok
;;; M-Eval input:
(f 10)
;;; M-Eval value:
110
計算機プログラムの構造と解釈
posted with amazlet at 08.11.07
ジェラルド・ジェイ サスマン ジュリー サスマン ハロルド エイブルソン
ピアソンエデュケーション
売り上げランキング: 6542
ピアソンエデュケーション
売り上げランキング: 6542
