99-haskell-problems/Problems 01-10/problem_08.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
)
[]