内容 4.1 The Metacircular Evaluator · 307
练习 自检推理
Exercise 4.6: Let expressions are derived
expressions, because
(let ((⟨var₁⟩ ⟨exp₁⟩) … (⟨varₙ⟩ ⟨expₙ⟩))
⟨body⟩)
is equivalent to
((lambda (⟨var₁⟩ … ⟨varₙ⟩)
⟨body⟩)
⟨exp₁⟩
…
⟨expₙ⟩)
Implement a syntactic transformation let->combination that reduces
evaluating let expressions to evaluating combinations of the type shown
above, and add the appropriate clause to eval to handle let
expressions.
练习 4.6:let 表达式是派生表达式,因为
(let ((⟨var₁⟩ ⟨exp₁⟩) … (⟨varₙ⟩ ⟨expₙ⟩))
⟨body⟩)
等价于
((lambda (⟨var₁⟩ … ⟨varₙ⟩)
⟨body⟩)
⟨exp₁⟩
…
⟨expₙ⟩)
实现一个语法变换过程 let->combination,将 let 表达式的求值化归为对上述形式的组合式求值,并在 eval 中加入适当的子句以处理 let 表达式。
SICP source code scheme
(let ((⟨var₁⟩ ⟨exp₁⟩) … (⟨varₙ⟩ ⟨expₙ⟩))
⟨body⟩) SICP source code scheme
((lambda (⟨var₁⟩ … ⟨varₙ⟩)
⟨body⟩)
⟨exp₁⟩
…
⟨expₙ⟩) 我的笔记 自动保存