dropWhileRev

Henning Thielemann lemming at henning-thielemann.de
Fri Aug 5 05:28:29 EDT 2005


Is this function worth to be added to Data.List?


{-| Remove the longest suffix of elements satisfying the predicate.
    In contrast to 'reverse . dropWhile p . reverse'
    this works for infinite lists, too. -}
dropWhileRev :: (a -> Bool) -> [a] -> [a]
dropWhileRev p =
   foldr (\x xs -> if p x && null xs then [] else x:xs) []



More information about the Libraries mailing list