take -package:vector package:bytestring

O(1) take n, applied to a ByteString xs, returns the prefix of xs of length n, or xs itself if n > length xs.
O(n/c) take n, applied to a ByteString xs, returns the prefix of xs of length n, or xs itself if n > length xs.
O(n) take n, applied to a ShortByteString xs, returns the prefix of xs of length n, or xs itself if n > length xs. Note: copies the entire byte array
O(1) takeEnd n xs is equivalent to drop (length xs - n) xs. Takes n elements from end of bytestring.
>>> takeEnd 3 "abcdefg"
"efg"

>>> takeEnd 0 "abcdefg"
""

>>> takeEnd 4 "abc"
"abc"
Similar to takeWhile, returns the longest (possibly empty) prefix of elements satisfying the predicate.
Returns the longest (possibly empty) suffix of elements satisfying the predicate. takeWhileEnd p is equivalent to reverse . takeWhile p . reverse.
takeWhile, applied to a predicate p and a ByteString xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p.
takeWhileEnd, applied to a predicate p and a ByteString xs, returns the longest suffix (possibly empty) of xs of elements that satisfy p.
O(c) takeEnd n xs is equivalent to drop (length xs - n) xs. Takes n elements from end of bytestring.
>>> takeEnd 3 "abcdefg"
"efg"

>>> takeEnd 0 "abcdefg"
""

>>> takeEnd 4 "abc"
"abc"
Returns the longest (possibly empty) suffix of elements satisfying the predicate. takeWhileEnd p is equivalent to reverse . takeWhile p . reverse.
>>> {-# LANGUAGE OverloadedLists #-)

>>> takeWhileEnd even [1,2,3,4,6]
[4,6]
Returns the longest (possibly empty) suffix of elements satisfying the predicate. takeWhileEnd p is equivalent to reverse . takeWhile p . reverse.
O(n) takeEnd n xs is equivalent to drop (length xs - n) xs. Takes n elements from end of bytestring.
>>> takeEnd 3 "abcdefg"
"efg"

>>> takeEnd 0 "abcdefg"
""

>>> takeEnd 4 "abc"
"abc"
Similar to takeWhile, returns the longest (possibly empty) prefix of elements satisfying the predicate.
Returns the longest (possibly empty) suffix of elements satisfying the predicate. takeWhileEnd p is equivalent to reverse . takeWhile p . reverse.
A variety of take which omits the checks on n so there is an obligation on the programmer to provide a proof that 0 <= n <= length xs.