From 7643f499bc4bde86cf91b8a99565ba392da42d3b Mon Sep 17 00:00:00 2001 From: Teun Duynstee Date: Mon, 3 Dec 2018 21:05:37 +0100 Subject: [PATCH 1/2] Added bigCombination to js-combinatorics --- types/js-combinatorics/index.d.ts | 8 ++++++++ types/js-combinatorics/js-combinatorics-tests.ts | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/types/js-combinatorics/index.d.ts b/types/js-combinatorics/index.d.ts index 6a5fa8e249..c1a3e85880 100644 --- a/types/js-combinatorics/index.d.ts +++ b/types/js-combinatorics/index.d.ts @@ -92,6 +92,14 @@ declare namespace __Combinatorics { */ function combination(a:T[], n?:number):IGenerator; + /** + * 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(a:T[], n?:number):IGenerator; + /** * Generates the permutation of array with n elements. * When n is ommited, the length of the array is used. diff --git a/types/js-combinatorics/js-combinatorics-tests.ts b/types/js-combinatorics/js-combinatorics-tests.ts index 68714ca17a..4162515bc2 100644 --- a/types/js-combinatorics/js-combinatorics-tests.ts +++ b/types/js-combinatorics/js-combinatorics-tests.ts @@ -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(); From 12cf8681cd911a6d93e36235d2ab27e717a841dc Mon Sep 17 00:00:00 2001 From: Teun Duynstee Date: Mon, 3 Dec 2018 21:16:35 +0100 Subject: [PATCH 2/2] incremented version in comment --- types/js-combinatorics/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/js-combinatorics/index.d.ts b/types/js-combinatorics/index.d.ts index c1a3e85880..702ef1f9a2 100644 --- a/types/js-combinatorics/index.d.ts +++ b/types/js-combinatorics/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for js-combinatorics v0.5.0 +// Type definitions for js-combinatorics v0.5.4 // Project: https://github.com/dankogai/js-combinatorics // Definitions by: Vasya Aksyonov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped