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
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
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
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 ...))])
> 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
5 matches
Mail list logo