Re: [racket] macro pattern problem

2015-01-26 Thread Matthias Felleisen
1. You should make your macro robust and deal with fewer than two elements in your uses. 2. Here is the same idea w/ syntax-rules: #lang racket (define-syntax quote-even (syntax-rules () [(_) '()] [(_ zero) (list 'zero)] [(_ zero one two ...) (list* 'zero one (quote-even two .

Re: [racket] macro pattern problem

2015-01-26 Thread Peter Samarin
Great, thanks! On 01/26/2015 10:57 PM, Alexander D. Knauth wrote: 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 (?@ 'a

Re: [racket] macro pattern problem

2015-01-26 Thread Alexander D. Knauth
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

[racket] macro pattern problem

2015-01-26 Thread Peter Samarin
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