
9 Nov
2009
9 Nov
'09
3:07 a.m.
Hi ! I am beginner in Haskell and have problems with this problem: compress :: Eq a => [a] -> [(a, Int)] If you have string "AAABCCC" it transforms it to : {A, 3} {B,1} {C,3}
Could you help me with it ? Thank you in advance !
This is straightforward with a list comprehension and the group function. import Data.List compress s = [(head g, length g) | g <- group s]