take -package:vector -package:utf8-string

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 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.
Take a given number of entries in key order, beginning with the smallest keys.
take n = fromDistinctAscList . take n . toAscList
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.
Take a given number of elements in order, beginning with the smallest ones.
take n = fromDistinctAscList . take n . toAscList
Consume exactly n bytes of input.
Consume exactly n characters of input.
Consume n bytes of input.
Stream up to n number of values downstream. Note that, if downstream terminates early, not all values will be consumed. If you want to force exactly the given number of values to be consumed, see takeExactly. Subject to fusion
Take some values from the stream and return as a list. If you want to instead create a conduit that pipes data to another sink, see isolate. This function is semantically equivalent to:
take i = isolate i =$ consume
Subject to fusion Since 0.3.0
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
Since 1.0.8
(take n) only allows n values to pass through
take 0 = return ()

take (m + n) = take m >> take n
take <infinity> = cat

take (min m n) = take m >-> take n
Make a list as long as another one
\(Shape xs) (List ys) -> Match.take xs ys == List.take (length xs) ys
Wraps an InputStream, producing a new InputStream that will produce at most n items, subsequently yielding end-of-stream forever. Items pushed back to the returned InputStream will be propagated upstream, modifying the count of taken items accordingly. Example:
ghci> is <- Streams.fromList [1..9::Int]
ghci> is' <- Streams.take 1 is
ghci> Streams.read is'
Just 1
ghci> Streams.read is'
Nothing
ghci> Streams.peek is
Just 2
ghci> Streams.unRead 11 is'
ghci> Streams.peek is
Just 11
ghci> Streams.peek is'
Just 11
ghci> Streams.read is'
Just 11
ghci> Streams.read is'
Nothing
ghci> Streams.read is
Just 2
ghci> Streams.toList is
[3,4,5,6,7,8,9]
End a stream after n elements; the original return value is thus lost. splitAt preserves this information. Note that, like splitAt, this function is functor-general, so that, for example, you can take not just a number of items from a stream of elements, but a number of substreams and the like.
>>> S.toList $ S.take 3 $ each "with"
"wit" :> ()
>>> S.readFile "stream.hs" (S.stdoutLn . S.take 3)
import Streaming
import qualified Streaming.Prelude as S
import Streaming.Prelude (each, next, yield)