Convert List of Tuples to List of Lists Haskell
haskell
Solution
Write a single function to convert a pair to a list:
pairToList :: (a, a) -> [a]
pairToList (x,y) = [x,y]
Then you only have to `map` `pairToList`:
tuplesToList :: [(a,a)] -> [[a]]
tuplesToList = map pairToList
Or in a single line:
map (\(x,y) -> [x,y])
Problem
I have `[("m","n"),("p","q"),("r","s")]`. How can I convert it to `[["m","n"],["p","q"],["r","s"]]`? Can anyone please help me? Thanks.