Skip to main content
Module

x/itertools/mod.ts>permutations

🦕 A TypeScript port of Python's itertools and more-itertools for Deno
Latest
function permutations
import { permutations } from "https://deno.land/x/itertools@v1.1.2/mod.ts";

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

If r is not specified, then r defaults to the length of the iterable and all possible full-length permutations are generated.

Permutations are emitted in lexicographic sort order. So, if the input iterable is sorted, the permutation tuples will be produced in sorted order.

Elements are treated as unique based on their position, not on their value. So if the input elements are unique, there will be no repeat values in each permutation.

Parameters

iterable: Iterable<T>
r: Maybe<number>

Returns

Iterable<Array<T>>