take {itertools2} | R Documentation |
Returns the first n
elements of an iterable object
as a list.
If n
is larger than the number of elements in object
, the
entire iterator is consumed.
take(object, n = 1)
object |
an iterable object |
n |
the number of elements to return in the list |
a list of the first n
items of the iterable object
take(iterators::iter(1:10), 3) # 1 2 3
take(iterators::iter(1:5), 10) # 1 2 3 4 5