Question: USING SCHEME LANGUAGE Implement def, which simulates a python def statement, allowing you to write code like (def f(x y) (+ x y)). (define-macro (
USING SCHEME LANGUAGE
Implement def, which simulates a python def statement, allowing you to write code like (def f(x y) (+ x y)).
(define-macro (def func bindings body)
'YOUR-CODE-HERE
)
Previously, my code is:
(define-macro (def func bindings body) `(begin (define-macro ,(cons 'x bindings) ,body) x))
However, the test case
(def f(x y) (+ x y))
expected f, while my code above got (lambda (x y) (+ x y))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
