[erlang-questions] [erlang-question] How to comprehend two lists synchronously?

Barco You barcojie@REDACTED
Fri Nov 18 06:45:58 CET 2011


Dear Erlangers,


I hope to get a list from two lists like this:
[{a1,b1}, {a2,b2}, {a3,b3}]      <-     [a1, a2 a3],  [b1, b2, b3].

But if I use list comprehension, I got:
10>  [{D1,D2} ||  D1 <- [a1,a2,a3], D2 <- [b1,b2,b3]].
[{a1,b1},
 {a1,b2},
 {a1,b3},
 {a2,b1},
 {a2,b2},
 {a2,b3},
 {a3,b1},
 {a3,b2},
 {a3,b3}]


So, my questions is how to comprehend list in synchronous way in order to
get what I want, rather than to compose the elements from two lists in all
possible situations.


Thank you,
Barco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111118/b448510c/attachment.htm>


More information about the erlang-questions mailing list