module Alea.List where -- Remove the nth element of a list. (0-indexed) -- RemoveAt 2 "abc" == ('c', "ab") removeAt :: Int -> [a] -> (a, [a]) removeAt n xs = (xs !! n, take n xs ++ drop (n+1) xs) -- Split a list into a list of lists -- ex. split "ab,cd,ef" ',' == ["ab","cd","ef"] split :: (Eq a) => [a] -> a -> [[a]] split [] _ = [[]] split (c:cs) delim | c == delim = [] : rest | otherwise = (c : head rest) : tail rest where rest = split cs delim