blob: 219bc93cbba12617a4dd7d67918db68a00f97f8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
compress :: (Eq a) => [a] -> [a]
compress = foldr elim []
where elim e [] = [e]
elim e ns
| e == head ns = ns
| otherwise = e:ns
compress' xs = foldr f (const []) xs Nothing
where
f x r a@(Just q)
| x == q = r a
f x r _ = x : r (Just x)
|