Skip to main content
Module

x/combinatorics/mod.ts

🦕 Combinatorial generators including combinations, permutations, combinations with replacement, permutations with replacement, cartesian products, and power sets.
Latest
import * as combinatorics from "https://deno.land/x/combinatorics@1.1.2/mod.ts";

Functions

Roughly equivalent to running nested for...of loops using one of the inputs to provide the element at each index for the yielded Array.

Yields r length Arrays from the input iterable. Order of selection does not matter and elements are chosen without replacement.

Yields r length Arrays from the input iterable. Order of selection is not important and elements are chosen with replacement.

Yields r length Arrays from the input iterable. Order of selection is important and elements are chosen without replacement. If r is undefined, then the length of the iterable is used.

Yields r length Arrays from the input iterable. Order of selection is important and elements are chosen with replacement.

The set of all subsets of the given iterable. Equivalent to running combinations with 0 <= r <= iterable.length and flattening the results. The first subset is the empty set given when r = 0.