2014-10-14 18:09:58 +02:00
|
|
|
module Alea.List where
|
2014-10-13 21:26:55 +02:00
|
|
|
|
2014-10-14 18:09:58 +02:00
|
|
|
-- Split a list into a list of lists
|
2014-10-16 23:00:52 +02:00
|
|
|
-- ex. split ',' "ab,cd,ef" == ["ab","cd","ef"]
|
|
|
|
split :: (Eq a) => a -> [a] -> [[a]]
|
|
|
|
split _ [] = [[]]
|
|
|
|
split delim (c:cs)
|
2014-12-13 01:05:02 +01:00
|
|
|
| c == delim = [] : rest
|
|
|
|
| otherwise = (c : head rest) : tail rest
|
|
|
|
where rest = split delim cs
|