take: Return the first n elements of an iterable object as a list

Description Usage Arguments Value Examples

Description

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.

Usage

1
take(object, n = 1)

Arguments

object

an iterable object

n

the number of elements to return in the list

Value

a list of the first n items of the iterable object

Examples

1
2
3
take(iterators::iter(1:10), 3) # 1 2 3

take(iterators::iter(1:5), 10) # 1 2 3 4 5

itertools2 documentation built on May 2, 2019, 3:37 p.m.