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

Barco You barcojie@REDACTED
Fri Nov 18 07:07:03 CET 2011

```Hi,

I'm not just doing zip, and what I showed is just an example. What I really
hope to do is to do some calculation involving two or more elements from
two or many lists, and of course the elements must from the same index in
all the lists.

Cheers!

> Hello.
>
> Use lists:zip/2:
>
> lists:zip([a,b,c], [1,2,3]) -> [{a,1},{b,2},{c,3}]
>
>
> HTH,
>
>
>
> ----- 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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111118/1dbbffe8/attachment.htm>
```