Hi!
I have a Problem with a lisp exercise. The problem is:
I have a lisp-dialekt without a let. Now the challenge is, to implement a
macro mylet that works similar. The binding should be done with a nameless
(lambda) function.
Thank you for any ideas!
Joachim
"Joachim" <········@fbma.tuwien.ac.at> writes:
> I have a lisp-dialekt without a let. Now the challenge is, to implement a
> macro mylet that works similar. The binding should be done with a nameless
> (lambda) function.
Like any macro exercise, this one has two parts.
1) figuring out how the macro expansion should look.
2) writing a macro definition that makes that expansion.
In this case:
1) What should this look like after macro expansion?
(mylet ((x 5) (y 6))
(frobnicate x y))
2) How do you write a macro definition that achieves that?
3) Once everything else is in place, start thinking about LET
variables without initial values. For example,
(mylet ((x 5) y)
(frobnicate x y))
should work the same as
(mylet ((x 5) (y nil))
(frobnicate x y))
So, which part is causing you problems?
Stig Hemmer,
Jack of a Few Trades.
* Joachim wrote:
> Hi!
> I have a Problem with a lisp exercise. The problem is:
> I have a lisp-dialekt without a let. Now the challenge is, to implement a
> macro mylet that works similar. The binding should be done with a nameless
> (lambda) function.
It's hard to answer this without giving the answer, but this might
give a clue as to the kind of construct you're looking for.
(defmacro for ((var list) &body code)
`(map nil #'(lambda (,var)
,@code)
,list))
--tim