Den lør. 21. sep. 2019 kl. 22.15 skrev Jonathan Simpson <[email protected] >:
> Given this macro that I'm experimenting with: > > (syntax-parse #'(1 2 2 a 2 2 b 2 c) [(1 (~seq n:nat ...+ x) ...) #'((n ... > x) ...)]) > > How would I change it so that it returns #'(2 2 a 2 2 b 2 c) instead of > #'((2 2 a) (2 2 b) (2 c)) ? > > I don't want the parens around the individual sequences that I'm matching, > but I haven't figured out a way to do this without using a pattern that > forces me to add them in the body of the syntax-parse clause. How can I > group the n and x pattern variables in the body without adding parens > around them? > > If could get a syntax class that replaces the (~seq n:nat ...+ x) that > might work but I haven't been able to get a syntax class that will do that > either. > Two options: (syntax-parse #'(1 2 2 a 2 2 b 2 c) [(1 (~seq n:nat ...+) x ...) #'(n ... x ...)]) (syntax-parse #'(1 2 2 a 2 2 b 2 c) [(1 n:nat ...+ x ...) #'(n ... x ...)]) /Jens Axel -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CABefVgxf-ORmDHZsSRv2G46FGbpUiFq7txnHK%2B2gdzEnb0RjYQ%40mail.gmail.com.

