[Haskell-cafe] Combine to List to a new List

Andrew Wagner wagner.andrew at gmail.com
Tue Jun 9 09:08:24 EDT 2009


Try c = zip a b

On Tue, Jun 9, 2009 at 9:05 AM, ptrash <ptrash at web.de> wrote:

>
> Hi,
>
> I have the following two lists:
>
> a = [1,2,3]
> b = ["A","B","C"]
>
> I want a combination of the to lists:
>
> c = [(1,"A"), (2, "B"), (3, "C")]
>
> How can I do this?
>
> I have tried
>
> c = [(x,y) | x <- a, y <- b]
>
> But this  just returns me a list with every possible combination of the 2
> lists.
>
> Thanks...
>
>
> --
> View this message in context:
> http://www.nabble.com/Combine-to-List-to-a-new-List-tp23942440p23942440.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090609/a4086bf3/attachment.html


More information about the Haskell-Cafe mailing list