
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.

Try c = zip a b
On Tue, Jun 9, 2009 at 9:05 AM, ptrash
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Probably you might need the "zip" function.Check here:http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:zip
Date: Tue, 9 Jun 2009 06:05:57 -0700 From: ptrash@web.de To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Combine to List to a new List
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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_________________________________________________________________ Windows Live™: Keep your life in sync. Check it out! http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009

Hey, cool. Thanks! -- View this message in context: http://www.nabble.com/Combine-to-List-to-a-new-List-tp23942440p23942633.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

On Tue, 2009-06-09 at 06:05 -0700, ptrash 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?
What you want is a function with the following type signature: [t1] -> [t2] -> [(t1,t2)] Search for that in hoogle[1] and you get the function "zip" as a result[2] (as already told in this thread). Hoogle is your friend (and helps you help yourself)! :) 1: http://haskell.org/hoogle/ 2: http://haskell.org/hoogle/?hoogle=%5Ba%5D+-%3E+%5Bb%5D+-%3E+%5B%28a% 2Cb%29%5D
participants (4)
-
Andrew Wagner
-
Dimitris Vekris
-
Mattias Bengtsson
-
ptrash