delta-h-0.0.1: src/Utils.hs
module Utils ( splitOn
, splitWith
, groupsOf
)
where
splitOn :: (Eq a) => a -> [a] -> [[a]]
splitOn = splitWith . (==)
splitWith :: (a -> Bool) -> [a] -> [[a]]
splitWith f s = case dropWhile f s of
[] -> []
s' -> w : splitWith f s''
where (w, s'') = break f s'
groupsOf n [] = []
groupsOf n xs = let (pre,xs') = splitAt n xs
in pre : groupsOf n xs'