I like that. I really need to level up on Racket macros!

On Wednesday, November 21, 2018 at 3:19:55 PM UTC-5, Matthew Butterick 
wrote:
>
>
> On Nov 21, 2018, at 9:30 AM, Brian Adkins <lojic...@gmail.com 
> <javascript:>> wrote:
>
> Thanks guys. I think I can live with:
>
> (for ([(i j) (in-dict '(("a" . 1) ("b" . 20)))])
>      (display (list i j)))
>
> I suppose I could also write something analogous to in-dict that would do 
> what I want. Maybe in-tuple ?
>
>
> Or perhaps:
>
> #lang racket
> (require (for-syntax racket/syntax))
>
> (define-syntax (match-for stx)
>   (syntax-case stx ()
>     [(_ ([PAT SEQ] ...) . BODY)
>      (with-syntax ([(TEMP ...) (map (λ (stx) (generate-temporary)) 
> (syntax->list #'(PAT ...)))])
>        #'(for ([TEMP SEQ] ...)
>               (match-let ([PAT TEMP] ...)
>                 . BODY)))]))
>
> (match-for ([(list i j) '(("a" 1) ("b" 20))])
>            (display (list i j)))
>

-- 
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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to