Function
Static Public Summary | ||
public |
permutations(iterable: Iterable, r: number): IterableIterator Yields all permutations of each possible choice of |
Static Private Summary | ||
private |
* _permutations(n: number, k: number): IterableIterator<IterableIterator<number>> Yields all k-permutations of {0, 1, ..., n-1}. |
Static Public
public permutations(iterable: Iterable, r: number): IterableIterator source
import permutations from '@combinatorics/n-permutations/src/permutations.js'
Yields all permutations of each possible choice of r
elements
of the input iterable.
Params:
Name | Type | Attribute | Description |
iterable | Iterable | The input iterable. |
|
r | number | The size of the permutations to generate. |
Return:
IterableIterator |
Example:
// AB AC AD BA BC BD CA CB CD DA DB DC
permutations('ABCD', 2) ;
// 012 021 102 120 201 210
permutations(range(3), 3) ;
Static Private
private * _permutations(n: number, k: number): IterableIterator<IterableIterator<number>> source
import _permutations from '@combinatorics/n-permutations/src/_permutations.js'
Yields all k-permutations of {0, 1, ..., n-1}.