I have this code:
lado :: [([Char],Int)] -> [[Char]]
lado xs = [a | (a,b) <- xs]
I need to output this:
> lado [("A
The transpose :: [[a]] -> [[a]] of [["A", "A", "A"], ["B", "B"], ["C"]]
is:
Prelude Data.List> transpose [["A", "A", "A"], ["B", "B"], ["C"]]
[["A","B","C"],["A","B"],["A"]]
if we then concatenate these with concat :: [[a]] -> [a], we get:
Prelude Data.List> concat (transpose [["A", "A", "A"], ["B", "B"], ["C"]])
["A","B","C","A","B","A"]
if we can thus make a lists of three "A"
s, two "B"
s, and one "C"
, then we can generate such list. I leave generating this list as an exercise. You can make use of replicate :: Int -> a -> [a] and use list comprehension, or map :: (a -> b) -> [a] -> [b].