I'm looking for a general solution. Basically, I thought binding multiple id's would have achieved what this does:
> (for/list ([t '((1 2 3) (4 5 6) (7 8 9) (a b c))]) (match-define (list x y z) t) (list x z)) '((1 3) (4 6) (7 9) (a c)) The way the documentation for `for` is worded [3], I thought if I could get the list of lists coerced into a being a sequence of multiple values, then the same thing could be achieved with: > (for/list ([(x y z) (??? '((1 2 3) (4 5 6) (7 8 9) (a b c))]) (list x z)) It looks like I would need a transpose-type operation before `apply`ing in-parallel, because this works, > (for/list ([(x y z) (in-parallel '(1 4 7 a) '(2 5 8 b) '(3 6 9 c))]) (list x z)) '((1 3) (4 6) (7 9) (a c)) [3] http://docs.racket-lang.org/reference/for.html : "...a location is created for each id to hold the values of each element; the sequence produced by a seq-expr must return as many values for each iteration as corresponding ids." On Mon, Jul 10, 2017 at 9:46 PM, Jon Zeppieri <zeppi...@gmail.com> wrote: > On Mon, Jul 10, 2017 at 11:40 PM, Nadeem Abdul Hamid <nad...@acm.org> > wrote: > > Given a list of pairs, I'm trying to iterate through the list and bind > the > > first and second elements of each pair to x and y, respectively, in each > > iteration. > > > > For example, hash sets are a multiple-valued sequence[1], so this: > > (for/list ([(x y) #hash((1 . 2) (3 . 4))]) x) > > produces: > > (list 1 3) > > > > i.e. here x gets bound to 1 in the first iteration and 3 in the second. I > > would like something analogous for a list of pairs, i.e. replacing #hash > > with ' : > > (for/list ([(x y) '((1 . 2) (3 . 4))]) x) > > except that lists are a by default a single-valued sequence[2]. > > > > > > in-dict will work for lists of pairs, like the ones in this example > (and it will work for hashes, as well), but it won't work for lists of > lists, like the examples in your previous message. Are lists of pairs > all you need to handle, or do you need something more general? > > -- > 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.