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