That's very cool.  Thank you, Matthew.

On Fri, Mar 3, 2017 at 6:50 PM, Matthew Butterick <m...@mbtype.com> wrote:

>
> On Mar 2, 2017, at 9:17 AM, David Storrs <david.sto...@gmail.com> wrote:
>
> I could, it's just extremely more verbose and therefore obfuscates what's
> actually going on as compared to the 'map' form.
>
>
> Why not turn it into a macro that preserves your preferred notation:
>
>
> #lang racket
> (struct foo (a b c) #:transparent)
> (define lst-A '(a b))
> (define lst-B '(d e))
>
> (require (for-syntax syntax/parse))
> (define-syntax (map-index stx)
>   (syntax-parse stx
>     #:datum-literals (current-index)
>     [(_ proc xs ... current-index ys ...)
>      (with-syntax ([(x-it ...) (generate-temporaries #'(xs ...))]
>                    [(y-it ...) (generate-temporaries #'(ys ...))])
>        #'(for/list ([x-it (in-list xs)] ... [y-it (in-list ys)] ...
>                     [index (in-naturals)])
>                    (proc x-it ... index y-it ...)))]))
>
> (map-index
>  foo
>  lst-A
>  lst-B
>  current-index) ; ; (list (foo 'a 'd 0) (foo 'b 'e 1))
>
> (map-index
>  foo
>  current-index
>  lst-A
>  lst-B) ; (list (foo 0 'a 'd) (foo 1 'b 'e))
>
> --
> 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.
>

-- 
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