summaryrefslogtreecommitdiff
path: root/src/Util.hs
blob: 4200e20794df8ab7b8312883c1a2cf618b1977dd (plain)
1
2
3
4
5
6
7
8
9
10
11
module Util where

uniq :: Eq a => [a] -> [a]
uniq (x:y:xs) | x == y    = uniq (x:xs)
              | otherwise = x : uniq (y:xs)
uniq xs = xs

uniqOn :: Eq b => (a -> b) -> [a] -> [a]
uniqOn f (x:y:xs) | f x == f y = uniqOn f (x:xs)
                  | otherwise  = x : uniqOn f (y:xs)
uniqOn _ xs = xs