How about:

(define-syntax (macro stx)
  (syntax-case stx ()
    [(_ (var1 ...) (var2 ...))
     #`(begin
        #,@(for*/list ((v1 (in-list (syntax->list #'(var1 ...))))
                       (v2 (in-list (syntax->list #'(var2 ...)))))
         #`(do-something #,v1 #,v2)))])) 

Jos

-----Original Message-----
From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On 
Behalf Of Sam Waxman
Sent: viernes, 01 de septiembre de 2017 11:37
To: Racket Users
Subject: [racket-users] Mapping over pattern variables

Lets say I have a macro

(define-syntax (macro stx)
  (syntax-parse stx
    [(_ (var1 ...) (var 2 ...))
     #'(begin
         (begin
           (do-something (#freeze var1) var2)
           ...)
         ...)]))

and I want to iterate first over var2, and then over var1. So if I type

(macro (1 2 3) (1 2))

I should get

(begin
  (begin
    (do-something 1 1)
    (do-something 1 2))
  (begin
    (do-something 2 1)
    (do-something 2 2))
  (begin
    (do-something 3 1)
    (do-something 3 2)))

What do I put where I currently have "#freeze" to tell the expander that I 
don't want the ... to affect var1? Or do I have to do
this manually with syntax->list and mapping functions?
         

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to