From 1dd4dd6f593521e0fca5d58457b216d3f4d80eb5 Mon Sep 17 00:00:00 2001 From: hasufell Date: Thu, 8 Jan 2015 01:38:18 +0100 Subject: [PATCH] PRELUDE add shiftM' --- MyPrelude.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MyPrelude.hs b/MyPrelude.hs index f495fe9..81da3b0 100644 --- a/MyPrelude.hs +++ b/MyPrelude.hs @@ -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