Skip to main content
Module

x/itertools/itertools.ts

🦕 A TypeScript port of Python's itertools and more-itertools for Deno
Go to Latest
import * as itertools from "https://deno.land/x/itertools@v1.1.1/itertools.ts";

Functions

Returns 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.

Non-lazy version of icompress().

Returns an iterator that counts up values starting with number start (default 0), incrementing by step. To decrement, use a negative step number.

Returns an iterator producing elements from the iterable and saving a copy of each. When the iterable is exhausted, return elements from the saved copy. Repeats indefinitely.

Returns an iterator that drops elements from the iterable as long as the predicate is true; afterwards, returns every remaining element. Note, the iterator does not produce any output until the predicate first becomes false.

Returns an iterator that filters elements from data returning only those that have a corresponding element in selectors that evaluates to true. Stops when either the data or selectors iterables has been exhausted.

Returns an iterator that filters elements from iterable returning only those for which the predicate is true.

Returns an iterator that computes the given mapper function using arguments from each of the iterables.

Returns an iterator that returns selected elements from the iterable. If start is non-zero, then elements from the iterable are skipped until start is reached. Then, elements are returned by making steps of step (defaults to 1). If set to higher than 1, items will be skipped. If stop is provided, then iteration continues until the iterator reached that index, otherwise, the iterable will be fully exhausted. islice() does not support negative values for start, stop, or step.

Returns an iterator that aggregates elements from each of the iterables. Used for lock-step iteration over several iterables at a time. When iterating over two iterables, use izip2. When iterating over three iterables, use izip3, etc. izip is an alias for izip2.

Like izip2, but for three input iterables.

Returns an iterator that aggregates elements from each of the iterables. If the iterables are of uneven length, missing values are filled-in with fillvalue. Iteration continues until the longest iterable is exhausted.

See izipLongest2, but for three.

Like the other izips (izip, izip3, etc), but generalized to take an unlimited amount of input iterables. Think izip(*iterables) in Python.

Return successive r-length permutations of elements in the iterable.

Returns an iterator that produces values over and over again. Runs indefinitely unless the times argument is specified.

Returns an iterator that produces elements from the iterable as long as the predicate is true.