How do I map a macro across a list in Scheme?

Posted by josh on Stack Overflow See other posts from Stack Overflow or by josh
Published on 2010-04-14T18:35:39Z Indexed on 2010/04/14 20:13 UTC
Read the original article Hit count: 164

Filed under:
|

I have a Scheme macro and a long list, and I'd like to map the macro across the list, just as if it were a function. How can I do that using R5RS?

The macro accepts several arguments:

(mac a b c d)

The list has

(define my-list ((a1 b1 c1 d1)
                 (a2 b2 c2 d2)
                 ...
                 (an bn cn dn)))

And I'd like to have this:

(begin
   (mac a1 b1 c1 d2)
   (mac a2 b2 c2 d2)
   ...
   (mac an bn cn dn))

(By the way, as you can see I'd like to splice the list of arguments too)

© Stack Overflow or respective owner

Related posts about Scheme

Related posts about macros