aureooms/js-permutation

View on GitHub
src/_permutations.js

Summary

Maintainability
A
0 mins
Test Coverage
import {_next} from './_next.js';

/**
 * Yields all permutations starting from a given one and ending at the last
 * permutation.
 *
 * @param {Array} sigma The starting permutation.
 * @param {number} n The size of the permutation.
 * @returns {IterableIterator} Iterator over all permutations between the starting one
 * and the last permutation on its elements.
 */
export function* _permutations(sigma, n) {
    do {
        yield sigma;
    } while (_next(sigma, n));
}