/** * combinatorics.js * * Licensed under the MIT license. * http://www.opensource.org/licenses/mit-license.php * * @author: Dan Kogai * * References: * @link: http://www.ruby-doc.org/core-2.0/Array.html#method-i-combination * @link: http://www.ruby-doc.org/core-2.0/Array.html#method-i-permutation * @link: http://en.wikipedia.org/wiki/Factorial_number_system * @link: https://en.wikipedia.org/wiki/Combinatorial_number_system */ export declare const version = "2.1.2"; /** * BigInt Workaround * * https://github.com/streamich/memfs/issues/275 */ type anyint = number | bigint; /** * Optional will not be official so * @link: https://github.com/microsoft/TypeScript/issues/19944 */ type Optional = T | undefined; /** * calculates `P(n, k)`. * * @link https://en.wikipedia.org/wiki/Permutation */ export declare function permutation(n: anyint, k: anyint): bigint; /** * calculates `C(n, k)`. * * @link https://en.wikipedia.org/wiki/Combination */ export declare function combination(n: anyint, k: anyint): bigint; /** * calculates `n!` === `P(n, n)`. * * @link https://en.wikipedia.org/wiki/Factorial */ export declare function factorial(n: anyint): bigint; /** * returns the factoradic representation of `n`, least significant order. * * @link https://en.wikipedia.org/wiki/Factorial_number_system * @param {number} l the number of digits */ export declare function factoradic(n: anyint, l?: number): number[]; /** * `combinadic(n, k)` returns a function * that takes `m` as an argument and * returns the combinadics representation of `m` for `n C k`. * * @link https://en.wikipedia.org/wiki/Combinatorial_number_system */ export declare function combinadic(n: anyint, k: anyint): (m: anyint) => number[]; /** * returns random integer `n` where `min` <= `n` < `max`: * * if the argument is `BigInt` the result is also `BigInt`. * * @param {anyint} min * @param {anyint} max */ export declare function randomInteger(min?: anyint, max?: anyint): anyint; /** * Base Class of `js-combinatorics` */ declare class _CBase { /** * does `new` * @param args */ static of(...args: any[]): any; /** * Same as `of` but takes a single array `arg` * * cf. https://stackoverflow.com/questions/1606797/use-of-apply-with-new-operator-is-this-possible */ static from(arg: any): any; /** * Common iterator */ [Symbol.iterator](): Generator; /** * returns `[...this]`. */ toArray(): U[][]; /** * @deprecated * tells wether you need `BigInt` to access all elements. */ get isBig(): boolean; /** * @deprecated * tells wether it is safe to work on this instance. * * * always `true` unless your platform does not support `BigInt`. * * if not, `true` iff `.isBig` is `false`. */ get isSafe(): boolean; /** * check n for nth */ _check(n: anyint): anyint; /** * get the `n`th element of the iterator. * negative `n` goes backwards * like `Array.prototype.at()` * @link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at */ at(n: anyint): Optional; /** * an alias of `at` */ nth(n: anyint): Optional; /** * the seed iterable */ seed: T[]; /** * the size (# of elements) of each element. */ size: number; /** * the number of elements */ length: bigint; /** * pick random element */ sample(): Optional; /** * an infinite steam of random elements */ samples(): Generator; } /** * Permutation */ export declare class Permutation extends _CBase { constructor(seed: Iterable, size?: number); at(n: anyint): Optional; } /** * Combination */ export declare class Combination extends _CBase { comb: (anyint: any) => number[]; constructor(seed: Iterable, size?: number); /** * returns an iterator which is more efficient * than the default iterator that uses .nth * * @link https://en.wikipedia.org/wiki/Combinatorial_number_system#Applications */ bitwiseIterator(): Generator; at(n: anyint): Optional; } /** * Base N */ export declare class BaseN extends _CBase { base: number; constructor(seed: Iterable, size?: number); at(n: anyint): Optional; } /** * Power Set */ export declare class PowerSet extends _CBase { constructor(seed: Iterable); at(n: anyint): Optional; } /** * Cartesian Product */ export declare class CartesianProduct extends _CBase { constructor(...args: Iterable[]); at(n: anyint): Optional; } export {};