Haskell takeWhile function

ID: haskell-takewhile-function

The higher-order function takeWhile :: (a -> Bool) -> [a] -> [a] retains the longest initial segment whose elements all satisfy its predicate. It stops at the first failure and does not resume later. Thus it differs from a list filter, which tests later elements as well.

New to topics? Read the docs here!