Hi guys,
I am having difficulties on how to write a function that will take a list of tuples and convert it to a list, example:
[(1,2), (3,4)] => [1,2,3,4]
can you please tell me how to do it?
One other thing, is there any way to write a function zipWith which is non-recursive, if there is how?
haskell: lists of tuples to list
Started by kunti, Sep 25 2008 08:47 PM
1 reply to this topic
#1
Posted 25 September 2008 - 08:47 PM
|
|
|
#2
Posted 31 October 2008 - 05:23 AM
Hey,
the two functions you requires are:
t2l :: (Int, Int) -> [Int]
t2l (a,b) = [a,b]
t2l2 :: [(Int, Int)] -> [Int]
t2l2 array = concat (map t2l array)
then you get this:
Cw2008> t2l2 [(1,2), (3,4)]
[1,2,3,4]
excuse the 'Cw2008>', I did it in my coursework file :)
a-z-z
the two functions you requires are:
t2l :: (Int, Int) -> [Int]
t2l (a,b) = [a,b]
t2l2 :: [(Int, Int)] -> [Int]
t2l2 array = concat (map t2l array)
then you get this:
Cw2008> t2l2 [(1,2), (3,4)]
[1,2,3,4]
excuse the 'Cw2008>', I did it in my coursework file :)
a-z-z


Sign In
Create Account

Back to top









