mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
Added bigCombination to js-combinatorics
This commit is contained in:
Vendored
+8
@@ -92,6 +92,14 @@ declare namespace __Combinatorics {
|
||||
*/
|
||||
function combination<T>(a:T[], n?:number):IGenerator<T[]>;
|
||||
|
||||
/**
|
||||
* Generates the combination of array with n elements, which
|
||||
* also supports larger sets of elements.
|
||||
* When n is ommited, the length of the array is used.
|
||||
* Somewhat slower than combination()
|
||||
*/
|
||||
function bigCombination<T>(a:T[], n?:number):IGenerator<T[]>;
|
||||
|
||||
/**
|
||||
* Generates the permutation of array with n elements.
|
||||
* When n is ommited, the length of the array is used.
|
||||
|
||||
@@ -25,6 +25,15 @@ const filteredCombinations:string[][] = combination.filter((i:string[]) => i.len
|
||||
const allCombinations:string[][] = combination.toArray();
|
||||
const combinationsCount = combination.length;
|
||||
|
||||
const limitedBigCombination = Combinatorics.bigCombination(["a", "b", "c"], 2);
|
||||
const bigCombination = Combinatorics.bigCombination(["a", "b", "c"]);
|
||||
const nextBigCombination:string[] = bigCombination.next();
|
||||
bigCombination.forEach((i:string[]) => console.log(i));
|
||||
const bigCombinationsLengths:number[] = bigCombination.map((i:string[]) => i.length);
|
||||
const filteredBigCombinations:string[][] = bigCombination.filter((i:string[]) => i.length > 0);
|
||||
const allBigCombinations:string[][] = bigCombination.toArray();
|
||||
const bigCombinationsCount = bigCombination.length;
|
||||
|
||||
const limitedPermutation = Combinatorics.permutation(["a", "b", "c"], 2);
|
||||
const permutation = Combinatorics.permutation(["a", "b", "c"]);
|
||||
const nextPermutation:string[] = permutation.next();
|
||||
|
||||
Reference in New Issue
Block a user