Skip to content

Commit

Permalink
Add spanEnd and breakEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Augustsson authored and Lennart Augustsson committed Nov 16, 2024
1 parent d8e05cf commit fe42bfc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Data/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Data.List(
iterate, iterate', repeat, replicate, cycle,
unfoldr,
take, drop, splitAt, takeWhile, takeWhileEnd, dropWhile, dropWhileEnd, span, spanUntil, break, splitWith,
spanEnd, breakEnd,
stripPrefix, stripSuffix, group, inits, tails,
isPrefixOf, isSuffixOf, isInfixOf, isSubsequenceOf,
elem, notElem, lookup,
Expand Down Expand Up @@ -379,6 +380,12 @@ span p =
break :: forall a . (a -> Bool) -> [a] -> ([a],[a])
break p = span (not . p)

spanEnd :: (a -> Bool) -> [a] -> ([a], [a])
spanEnd p xs = (dropWhileEnd p xs, takeWhileEnd p xs)

breakEnd :: (a -> Bool) -> [a] -> ([a], [a])
breakEnd p = spanEnd (not . p)

spanUntil :: forall a . (a -> Bool) -> [a] -> ([a], [a])
spanUntil p =
let
Expand Down

0 comments on commit fe42bfc

Please sign in to comment.