alea/Alea/List.hs
2014-10-20 16:54:23 +02:00

12 lines
283 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