take -package:conduit
take n, applied to a list
xs, returns the
prefix of
xs of length
n, or
xs itself if
n >= length xs.
It is an instance of the more general
genericTake, in which
n may be of any integral type.
Laziness
>>> take 0 undefined
[]
>>> take 2 (1 : 2 : undefined)
[1,2]
Examples
>>> take 5 "Hello World!"
"Hello"
>>> take 3 [1,2,3,4,5]
[1,2,3]
>>> take 3 [1,2]
[1,2]
>>> take 3 []
[]
>>> take (-1) [1,2]
[]
>>> take 0 [1,2]
[]
take n xs returns the first
n elements of
xs.
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(n) take n, applied to a
Text, returns
the prefix of the
Text of length
n, or the
Text
itself if
n is greater than the length of the Text.
O(n) take n, applied to a stream, returns the
prefix of the stream of length
n, or the stream itself if
n is greater than the length of the stream.
Properties
unstream . take n . stream = take n
O(n) take n, applied to a
Text, returns
the prefix of the
Text of length
n, or the
Text
itself if
n is greater than the length of the Text.
The first
i elements of a sequence. If
i is negative,
take i s yields the empty
sequence. If the sequence contains fewer than
i elements, the
whole sequence is returned.
Consume exactly n bytes of input.
Consume exactly n characters of input.
Consume n bytes of input.
take n s returns the first n characters of
s. If s has less than n characters, then we
return the whole of s.
take n s returns the first n characters of
s. If s has less than n characters, then we
return the whole of s.
take n s returns the first n characters of
s. If s has less than n characters, then we
return the whole of s.
take n s returns the first n characters of
s. If s has less than n characters, then we
return the whole of s.
take n, applied to a list
xs, returns the
prefix of
xs of length
n, or
xs itself if
n >= length xs.
>>> take 5 "Hello World!"
"Hello"
>>> take 3 [1,2,3,4,5]
[1,2,3]
>>> take 3 [1,2]
[1,2]
>>> take 3 []
[]
>>> take (-1) [1,2]
[]
>>> take 0 [1,2]
[]
It is an instance of the more general
genericTake, in which
n may be of any integral type.
Take the first n byte of a bytearray
Take @n bytes from the current position in the stream
Take the first n byte of a bytearray
Take the given number of bytes, if available.
Since 0.3.0