syntax/parse can do that: #lang racket (require (for-syntax racket/base syntax/parse syntax/parse/experimental/template)) (define-syntax quote-even (syntax-parser [(quote-even (~seq att val) ...) (template (list (?@ 'att val) ...))])) (quote-even a 1 b 2) ; '(a 1 b 2)
On Jan 26, 2015, at 4:48 PM, Peter Samarin <petrsama...@gmail.com> wrote: > Hello all, > > I want to quote every even and evaluate every odd variable of the input and > assemble everything in a list. > So I wrote the following macro to do it: > > (define-syntax quote-even > (syntax-rules () > [(quote-even att val ...) > (list 'att val ...)])) > > But in the resulting list, only the very first attribute is quoted: > > (syntax->datum > (expand-once > '(quote-even a 10 b 20 c 30))) > > > (list 'a 10 b 20 c 30) > > (quote-even a 10 b 20 c 30) > > b: undefined; > > > Is there a way to do do it? > > Cheers, > Peter Samarin > ____________________ > Racket Users list: > http://lists.racket-lang.org/users ____________________ Racket Users list: http://lists.racket-lang.org/users