blob: 485cba8e816899f9de39eb34553a0b86f659f50e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
module Data.List.Extended
( module Data.List
, breakWhen
) where
import Data.List
-- | Like 'break', but can act on the entire tail of the list.
breakWhen :: ([a] -> Bool) -> [a] -> ([a], [a])
breakWhen predicate = go []
where
go buf [] = (reverse buf, [])
go buf (x : xs)
| predicate (x : xs) = (reverse buf, x : xs)
| otherwise = go (x : buf) xs
|