I am trying to map let and set! onto lists something like this:
(map (lambda (x) (let ((x #f)))) <list>)
and
(map set! <list1> <list2>)
But, of course, neither is working.
Is there a way to do this? Any advice is appreciated.
Thanks.
The real problem is that I am trying to find a way to pattern match letrec. I need to be able to pattern match:
(letrec ((var val) ...) expr0 expr1 ...)
and convert it -- using match-lambda -- to an equivalent call using only let and set! This is the template I am trying to emulate:
(letrec ((var val) ...) expr0 expr1 ...)
==>
(let ((var #f) ...)
(let ((temp val) ...)
(set! var temp) ...
(let () expr0 expr1 ...)))
The problem is translating this into syntax that match-lambda accepts. Here is what I was working on, assuming there was a way to accomplish the original question:
(match-rewriter (`(letrec((,<var> ,<val>) ...) ,<expr> ...)
`((map (λ (x) (let ((x #f)))) ,<var>)
(let ((temp ,<val>)))
(map set! ,<var> temp)
(let () ,@<expr>))))
Any advice is appreciated.
Thanks.