Home Manual Reference Source

Function

Static Public Summary
public

combinations(iterable: Iterable, r: number): IterableIterator<Array>

Yields all combinations of each possible choice of r elements of the input iterable.

Static Private Summary
private

* _combinations(n: number, k: number): IterableIterator<number[]>

Yields all k-subsets of {0, 1, ..., n-1}.

Static Public

public combinations(iterable: Iterable, r: number): IterableIterator<Array> source

Yields all combinations of each possible choice of r elements of the input iterable.

Params:

NameTypeAttributeDescription
iterable Iterable

The input iterable.

r number

The size of the combinations to generate.

Return:

IterableIterator<Array>

Example:

// AB AC AD BC BD CD
combinations('ABCD', 2)
// 012 013 023 123
combinations(range(4), 3)

Static Private

private * _combinations(n: number, k: number): IterableIterator<number[]> source

Yields all k-subsets of {0, 1, ..., n-1}.

Params:

NameTypeAttributeDescription
n number
k number

Return:

IterableIterator<number[]>