99-haskell-problems/Problems 1-10/problem_8.hs

10 lines
171 B
Haskell

compress :: (Eq a) => [a] -> [a]
compress =
foldr
( \x acc ->
if acc /= []
&& x == head acc
then acc
else x : acc
)
[]