Add more sounds

This commit is contained in:
2022-06-23 21:23:45 +01:00
parent 8d266a6770
commit fb3f677957
17 changed files with 291 additions and 228 deletions
+16 -1
View File
@@ -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