PRELUDE add shiftM'

This commit is contained in:
hasufell 2015-01-08 01:38:18 +01:00
parent 550957da13
commit 1dd4dd6f59
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020

View File

@ -93,6 +93,12 @@ shiftM 0 xs = xs
shiftM n xs = drop n xs ++ take n xs
-- |Shift a list.
-- E.g.: shiftM' (== 5)
shiftM' :: Eq a => a -> [a] -> [a]
shiftM' s xs = dropWhile (/= s) xs ++ takeWhile (/= s) xs
-- |Get the pivot of a list.
pivot :: [a] -> Maybe a
pivot [] = Nothing