Switch parameters order
This commit is contained in:
parent
95e0a5732e
commit
ac5831f063
10
Alea/List.hs
10
Alea/List.hs
@ -6,11 +6,11 @@ removeAt :: Int -> [a] -> (a, [a])
|
|||||||
removeAt n xs = (xs !! n, take n xs ++ drop (n+1) xs)
|
removeAt n xs = (xs !! n, take n xs ++ drop (n+1) xs)
|
||||||
|
|
||||||
-- Split a list into a list of lists
|
-- Split a list into a list of lists
|
||||||
-- ex. split "ab,cd,ef" ',' == ["ab","cd","ef"]
|
-- ex. split ',' "ab,cd,ef" == ["ab","cd","ef"]
|
||||||
split :: (Eq a) => [a] -> a -> [[a]]
|
split :: (Eq a) => a -> [a] -> [[a]]
|
||||||
split [] _ = [[]]
|
split _ [] = [[]]
|
||||||
split (c:cs) delim
|
split delim (c:cs)
|
||||||
| c == delim = [] : rest
|
| c == delim = [] : rest
|
||||||
| otherwise = (c : head rest) : tail rest
|
| otherwise = (c : head rest) : tail rest
|
||||||
where
|
where
|
||||||
rest = split cs delim
|
rest = split delim cs
|
||||||
|
Loading…
Reference in New Issue
Block a user