[erlang-questions] [erlang-question] How to comprehend two lists synchronously?
lenartlad@REDACTED
lenartlad@REDACTED
Fri Nov 18 06:57:10 CET 2011
Hello.
Use lists:zip/2:
lists:zip([a,b,c], [1,2,3]) -> [{a,1},{b,2},{c,3}]
HTH,
Ladislav Lenart
----- PŮVODNÍ ZPRÁVA -----
Od: "Barco You" <barcojie@REDACTED>
Komu: "erlang-questions" <erlang-questions@REDACTED>
Předmět: [erlang-questions] [erlang-question] How to comprehend two
Datum: 18.11.2011 - 6:45:58
> 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
>
--
Videokurzy MS Office zdarma! Portál VOLNÝ.cz přináší online výuková
videa, která vás rychle, názorně a zábavnou formou naučí ovládat
programy Excel, Word a PowerPoint. Seriál najdete na
http://web.volny.cz/data/click.php?id=1293
More information about the erlang-questions
mailing list