I need to be able to match patterns like this:
(lambda (<param> ...) <stmt> ...)
using match-lambda and return something like this:
(CLOSURE ENV '(<param> ...) (λ (ENV) <stmt> ...)
where the list of parameters is quoted.
The closest I can get is:
(`(lambda (,<param> . ,<params>) . ,<stmts>)
`(CLOSURE ENV (,<param> . <params>) (lambda (ENV) (,@<stmts>))))
For instance, '(lambda (ls1 ls2) (append ls1 ls2))) returns:
'(CLOSURE
ENV
(ls1 ls2)
(lambda (ENV) ((append ls1 ls2))))
but I can't get the parameter list to be quoted.
In answers to previous posts I have been told that the "." in the pattern must precede the last element in a list. However I have found that this isn't correct. For instance:
(define function-call
(match-rewriter
(`(,<func> . ,<args>)
`(CALL ,<func> (list ,@<args>)))) (+ 1 2) )
returns:
'(CALL + (list 1 2))
where args has clearly match both the 1 and the 2.
If anyone can give me some advice on how to fix this pattern it would be greatly appreciated.
Thanks.