module W04_3 where import Prelude hiding (dropWhile, takeWhile) -- Drop a consecutive block of elements fulfilling the given predicate -- -- Example: dropWhile (< 5) [1, 2, 3, 4, 5, 6] = [5, 6] -- dropWhile :: (a -> Bool) -> [a] -> [a] dropWhile p [] = [] -- DELETE dropWhile p (x:xs) | p x = dropWhile p xs -- FOR THE | otherwise = x:xs -- LECTURE -- Retain a consecutive block of elements fulfilling the given predicate -- -- Example: dropWhile (< 5) [1, 2, 3, 4, 5, 6] = [1, 2, 3, 4] -- takeWhile :: (a -> Bool) -> [a] -> [a] takeWhile p [] = [] -- DELETE takeWhile p (x:xs) | p x = x : takeWhile p xs -- FOR THE | otherwise = [] -- LECTURE