alea/Alea/List.hs
Michele Guerini Rocco 7ec9fbe884 Fix whitespace
2014-12-13 01:05:02 +01:00

11 lines
284 B
Haskell

module Alea.List where
-- Split a list into a list of lists
-- ex. split ',' "ab,cd,ef" == ["ab","cd","ef"]
split :: (Eq a) => a -> [a] -> [[a]]
split _ [] = [[]]
split delim (c:cs)
| c == delim = [] : rest
| otherwise = (c : head rest) : tail rest
where rest = split delim cs