Add more sounds
This commit is contained in:
+16
-1
@@ -7,9 +7,24 @@ module ListHelp
|
||||
, safeHead
|
||||
, safeUncons
|
||||
, errorHead
|
||||
)where
|
||||
, foldPairs
|
||||
, loopPairs
|
||||
) where
|
||||
import Data.List
|
||||
|
||||
loopPairs :: [a] -> [(a,a)]
|
||||
loopPairs (a:as) = snd $ foldr f (Just a,[]) (a:as)
|
||||
where
|
||||
f x (Nothing,ps) = (Just x,ps)
|
||||
f x (Just y,ps) = (Just x,(x,y):ps)
|
||||
loopPairs [] = error "tried to make loop with empty list of elements"
|
||||
|
||||
foldPairs :: [a] -> [(a,a)]
|
||||
foldPairs = snd . foldr f (Nothing, [])
|
||||
where
|
||||
f x (Nothing,ps) = (Just x,ps)
|
||||
f x (Just y,ps) = (Just x,(x,y):ps)
|
||||
|
||||
initOrNull :: [a] -> [a]
|
||||
initOrNull [] = []
|
||||
initOrNull xs = init xs
|
||||
|
||||
Reference in New Issue
Block a user