Jens Axel Søgaard writes:
> Here are two variations:
...
Alexander D. Knauth writes:
> To make it look a little less messy, here's what I would do for stuff like
> this:
...
Matthias Felleisen writes:
> I think you want either this:
...
Ryan Culpepper writes:
> Here's one more solution
Here's one more solution, using "template metafunctions" (inspired by
Redex's metafunctions). And yes, most of the point of template
metafunctions is to have something that cooperates with ellipses like
you want.
> (require syntax/parse
syntax/parse/experimental/template
I think you want either this:
(syntax-parse #'(foo a b c)
[(f:id s:id ...)
(map (λ (s) (format-id #'f "foo-~a" s)) (syntax->list #'(s ...)))])
or that:
(syntax-parse #'(foo a b c)
[(f:id s:id ...)
#'(list (format-id #'f "foo-~a" #'s) ...)])
On Sep 2, 2015, at 7:00 AM, Konrad Hinsen wr
> On Sep 2, 2015, at 7:09 AM, Konrad Hinsen wrote:
>
> Konrad Hinsen writes:
>
>> In fact, what I want is do something like map over the ellipsis pattern,
>> but I haven't seen any example for doing this.
>
> Well, map actually works:
>
> (syntax-parse #'(foo a b c)
>[(f:id s:id ...)
>
Here are two variations:
#lang racket
(require syntax/stx syntax/parse racket/syntax unstable/sequence)
(syntax-parse #'(foo a b c)
[(f:id s:id ...)
(define foo-s* (stx-map (λ (x) (format-id #'f "foo-~a" x)) #'(s ...)))
(with-syntax ([(foo-s ...) foo-s*])
#'(list foo-s ...))])
(sy
Konrad Hinsen writes:
> In fact, what I want is do something like map over the ellipsis pattern,
> but I haven't seen any example for doing this.
Well, map actually works:
(syntax-parse #'(foo a b c)
[(f:id s:id ...)
(with-syntax ([(foo-s ...)
(map (λ (x) (format
Hi everyone,
I am working on what I consider a simple macro, but after reading all
of the macro-related documentation twice, I still don't see how to do
this.
I want to transform
(foo a b c)
to
(list foo-a foo-b foo-c)
Here is my best attempt (using syntax/parse):
(syntax-parse #'(foo a
7 matches
Mail list logo