Problem 7 (200pts): lambda
2022年12月5日22:00更新:
如果你遇到了
<xxx> is not defined
的情况,请删除代码文件夹中的scheme
文件(注意不是删除scheme.py
文件)!
Implement the do_lambda_form
function (spec), which creates and returns a LambdaProcedure
instance.
While you cannot call a user-defined procedure yet, you can verify that you have created the procedure correctly by typing a lambda expression into the interpreter prompt:
scm> (lambda (x y) (+ x y))
(lambda (x y) (+ x y))
In Scheme, it is legal to place more than one expression in the body of a procedure.
(There must be at least one expression.)
The body
attribute of a LambdaProcedure
instance is therefore a Scheme list of body expressions.
Like a begin
special form, evaluating the body of a procedure evaluates all body expressions in order.
The return value of a procedure is the value of its last body expression.
Before writing any code, unlock the tests to verify your understanding of the question:
$ python3 ok -q 07 -u
Once you are done unlocking, begin implementing your solution. You can check your correctness with:
$ python3 ok -q 07