intertools
Starlark module for working with iterators library.
This module implements a number of iterator building blocks inspired by constructs from APL, Haskell, and SML. Each has been recast in a form suitable for Python. The module standardizes a core set of fast, memory efficient tools that are useful by themselves or in combination. Together, they form an “iterator algebra” making it possible to construct specialized tools succinctly and efficiently in pure Python.
Similar to itertools in Python.
itertools.chain(*iterables)
Make an iterator that returns elements from the first iterable until it is exhausted, then proceeds to the next iterable, until all of the iterables are exhausted. Used for treating consecutive sequences as a single sequence.
Example:
chain(['ABC', 'DEF'], ['GHI'])
['ABC', 'DEF', 'GHI']
Parameters:
iterables - iterables to chain.
Returns: new iterable, that contains content of iterables.
itertools.from_iterable(iterables)
Alternate constructor for chain(). Gets chained inputs from a single iterable argument that is evaluated lazily. Same as chain()
Parameters:
iterables - iterables to chain.
Returns: new iterable, that contains content of iterables.
Last updated