Problem 7 (200pts): lambda
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:
$ python ok -q 07 -u
Once you are done unlocking, begin implementing your solution. You can check your correctness with:
$ python ok -q 07