break

break, applied to a predicate p and a list xs, returns a tuple where first element is longest prefix (possibly empty) of xs of elements that do not satisfy p and second element is the remainder of the list: break p is equivalent to span (not . p) and consequently to (takeWhile (not . p) xs, dropWhile (not . p) xs), even if p is _|_.

Laziness

>>> break undefined []
([],[])
>>> fst (break (const True) undefined)
*** Exception: Prelude.undefined
>>> fst (break (const True) (undefined : undefined))
[]
>>> take 1 (fst (break (const False) (1 : undefined)))
[1]
break produces the first component of the tuple lazily:
>>> take 10 (fst (break (const False) [1..]))
[1,2,3,4,5,6,7,8,9,10]

Examples

>>> break (> 3) [1,2,3,4,1,2,3,4]
([1,2,3],[4,1,2,3,4])
>>> break (< 9) [1,2,3]
([],[1,2,3])
>>> break (> 9) [1,2,3]
([1,2,3],[])
The break p function is equivalent to span (not . p).
Similar to break, returns the longest (possibly empty) prefix of elements which do not satisfy the predicate and the remainder of the string. break p is equivalent to span (not . p) and to (takeWhile (not . p) &&& dropWhile (not . p)). Under GHC, a rewrite rule will transform break (==) into a call to the specialised breakByte:
break ((==) x) = breakByte x
break (==x) = breakByte x
break p is equivalent to span (not . p).
Similar to break, returns the longest (possibly empty) prefix of elements which do not satisfy the predicate and the remainder of the string. break p is equivalent to span (not . p) and to (takeWhile (not . p) &&& dropWhile (not . p)).
Similar to break, returns the longest (possibly empty) prefix of elements which do not satisfy the predicate and the remainder of the string. break p is equivalent to span (not . p) and to (takeWhile (not . p) &&& dropWhile (not . p)).
O(n) break is like span, but the prefix returned is over elements that fail the predicate p.
>>> T.break (=='c') "180cm"
("180","cm")
Split a string into two parts: the first is the longest prefix that contains only characters that do not satisfy the predicate; the second part is the rest of the string. Invalid characters are passed as '\0xFFFD' to the predicate.
Split a string into two parts: the first is the longest prefix that contains only characters that do not satisfy the predicate; the second part is the rest of the string. Invalid characters are passed as '\0xFFFD' to the predicate.
Split a string into two parts: the first is the longest prefix that contains only characters that do not satisfy the predicate; the second part is the rest of the string. Invalid characters are passed as replacement_char to the predicate.
break, applied to a predicate p and a list xs, returns a tuple where first element is longest prefix (possibly empty) of xs of elements that do not satisfy p and second element is the remainder of the list:
>>> break (> 3) [1,2,3,4,1,2,3,4]
([1,2,3],[4,1,2,3,4])

>>> break (< 9) [1,2,3]
([],[1,2,3])

>>> break (> 9) [1,2,3]
([1,2,3],[])
break p is equivalent to span (not . p).
It is Data.List.span f undefined = undefined, whereas span f undefined = (undefined, undefined).
Break a sequence upon meeting element falls under a predicate, keeping it and the rest of the stream as the return value.
>>> rest <- S.print $ S.break even $ each [1,1,2,3]
1
1

>>> S.print rest
2
3
break p is equivalent to span (not . p). Under GHC, a rewrite rule will transform break (==) into a call to the specialised breakByte:
break ((==) x) = breakByte x
break (==x) = breakByte x
break p is equivalent to span (not . p).
break, applied to a predicate p and a list xs, returns a tuple where first element is longest prefix (possibly empty) of xs of elements that do not satisfy p and second element is the remainder of the list:
break (> 3) [1,2,3,4,1,2,3,4] == ([1,2,3],[4,1,2,3,4])
break (< 9) [1,2,3] == ([],[1,2,3])
break (> 9) [1,2,3] == ([1,2,3],[])
break p is equivalent to span (not . p).
O(n) break is like span, but the prefix returned is over elements that fail the predicate p.
O(n) Split the vector into the longest prefix of elements that do not satisfy the predicate and the rest without copying.
O(n) Split the vector into the longest prefix of elements that do not satisfy the predicate and the rest without copying.
O(n) Split the vector into the longest prefix of elements that do not satisfy the predicate and the rest without copying.
O(n) Split the vector into the longest prefix of elements that do not satisfy the predicate and the rest without copying.
break applies a predicate to a sequence, and returns a tuple where the first element is the longest prefix (possibly empty) of elements that do not satisfy the predicate. The second element of the tuple is the remainder of the sequence. break p is equivalent to span (not . p)
> break (> 3) (fromList [1,2,3,4,1,2,3,4] :: Vector Int)
(fromList [1,2,3],fromList [4,1,2,3,4])

> break (< z) (fromList "abc" :: Text)
("","abc")

> break (> z) (fromList "abc" :: Text)
("abc","")
Variant of span with negated predicate.
>>> break (> 'c') "abcdabcd"
("abc","dabcd")
break p t == span (not . p) t
fst (break p t) <> snd (break p t) == t
Improper lens that splits after the longest consecutive group of bytes that fail the given predicate