mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
Merge pull request #31026 from Teun/big-combination
js-combinatorics: Added bigCombination function
This commit is contained in:
Vendored
+9
-1
@@ -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 <https://github.com/outring>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -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