**break**

break, applied to a predicate p and a list xs, returns a tuple (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.
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
breakByte breaks its ByteString argument at the first occurence of the specified byte. It is more efficient than break as it is implemented with memchr(3). I.e.
> break (=='c') "abcd" == breakByte 'c' "abcd"
*O(i)* applied to a predicate p and a sequence xs, returns a pair whose first element is the longest prefix (possibly empty) of xs of elements that *do not satisfy* p and the second element is the remainder of the sequence.
breakl p is equivalent to spanl (not . p).
*O(n+m)* Find the first instance of needle (which must be non-null) in haystack. The first element of the returned tuple is the prefix of haystack before needle is matched. The second is the remainder of haystack, starting with the match.
Examples:
> breakOn "::" "a::b::c" ==> ("a", "::b::c")
> breakOn "/" "foobar" ==> ("foobar", "")
Laws:
> append prefix match == haystack
>
If you need to break a string by a substring repeatedly (e.g. you want to break on every instance of a substring), use breakOnAll instead, as it has lower startup overhead.
In (unlikely) bad cases, this function's time complexity degrades towards *O(n*m)*.
*O(n+m)* Find the first instance of needle (which must be non-null) in haystack. The first element of the returned tuple is the prefix of haystack before needle is matched. The second is the remainder of haystack, starting with the match.
Examples:
> breakOn "::" "a::b::c" ==> ("a", "::b::c")
> breakOn "/" "foobar" ==> ("foobar", "")
Laws:
> append prefix match == haystack
>
If you need to break a string by a substring repeatedly (e.g. you want to break on every instance of a substring), use breakOnAll instead, as it has lower startup overhead.
This function is strict in its first argument, and lazy in its second.
In (unlikely) bad cases, this function's time complexity degrades towards *O(n*m)*.
*O(n+m)* Find all non-overlapping instances of needle in haystack. Each element of the returned list consists of a pair:
* The entire string prior to the *k*th match (i.e. the prefix)
* The *k*th match, followed by the remainder of the string
Examples:
> breakOnAll "::" ""
> ==> []
> breakOnAll "/" "a/b/c/"
> ==> [("a", "/b/c/"), ("a/b", "/c/"), ("a/b/c", "/")]
In (unlikely) bad cases, this function's time complexity degrades towards *O(n*m)*.
The needle parameter may not be empty.

*O(n+m)* Find all non-overlapping instances of needle in haystack. Each element of the returned list consists of a pair:
* The entire string prior to the *k*th match (i.e. the prefix)
* The *k*th match, followed by the remainder of the string
Examples:
> breakOnAll "::" ""
> ==> []
> breakOnAll "/" "a/b/c/"
> ==> [("a", "/b/c/"), ("a/b", "/c/"), ("a/b/c", "/")]
This function is strict in its first argument, and lazy in its second.
In (unlikely) bad cases, this function's time complexity degrades towards *O(n*m)*.
The needle parameter may not be empty.

*O(n+m)* Similar to breakOn, but searches from the end of the string.
The first element of the returned tuple is the prefix of haystack up to and including the last match of needle. The second is the remainder of haystack, following the match.
> breakOnEnd "::" "a::b::c" ==> ("a::b::", "c")
A simple Breakout game implementation.
Version 0.0.2

otherwise -> Just (length x) </pre>
For example, to tokenise a string, dropping delimiters:
> tokenise x y = h (:) if null t then [] else tokenise x (drop (length x) t)
>
To skip to the first occurence of a string:
> snd (breakSubstring x y)
To take the parts of a string before a delimiter:
> fst (breakSubstring x y)

Show more results