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

Mattias Bengtsson moonlite at dtek.chalmers.se
Tue Jun 9 09:39:30 EDT 2009


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



More information about the Haskell-Cafe mailing list