js-combinatorics
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -22,3 +22,3 @@ /* | ||
'use strict'; | ||
var version = "0.5.2"; | ||
var version = "0.5.3"; | ||
/* combinatory arithmetics */ | ||
@@ -91,2 +91,14 @@ var P = function(m, n) { | ||
}, | ||
find: function(f) { | ||
var e, result; | ||
this.init(); | ||
while (e = this.next()) { | ||
if (f(e)) { | ||
result = e; | ||
break; | ||
} | ||
} | ||
this.init(); | ||
return result; | ||
}, | ||
lazyMap: function(f) { | ||
@@ -337,3 +349,9 @@ this._lazyMap = f; | ||
init: function() { | ||
this.cmb = combination(ary, nelem); | ||
/* combination can only be used for less than 31 elements */ | ||
if (ary.length < 31) { | ||
this.cmb = combination(ary, nelem); | ||
} else { | ||
this.cmb = bigCombination(ary, nelem); | ||
} | ||
this.per = _permutation(this.cmb.next()); | ||
@@ -340,0 +358,0 @@ }, |
Package.describe({ | ||
name: 'jandres:js-combinatorics', | ||
version: '0.5.2', | ||
version: '0.5.3', | ||
// Brief, one-line summary of the package. | ||
@@ -5,0 +5,0 @@ summary: 'power set, combination, permutation and more in JavaScript', |
{ | ||
"name": "js-combinatorics", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Simple combinatorics like power set, combination, and permutation in JavaScript", | ||
@@ -28,5 +28,5 @@ "main": "combinatorics.js", | ||
"author": "Dan Kogai", | ||
"license": "BSD", | ||
"license": "MIT", | ||
"readmeFilename": "README.md", | ||
"gitHead": "e3684eb54f7c6fbb24bb7a4d08d88671ce12e9eb" | ||
} |
@@ -36,3 +36,3 @@ [![build status](https://secure.travis-ci.org/dankogai/js-combinatorics.png)](http://travis-ci.org/dankogai/js-combinatorics) | ||
cmb = Combinatorics.power(['a','b','c']); | ||
cmb.each(function(a){ console.log(a) }); | ||
cmb.forEach(function(a){ console.log(a) }); | ||
// [] | ||
@@ -256,2 +256,7 @@ // ["a"] | ||
#### .find(function(a){ ... }) | ||
Returns the first element that passes the filter function, or | ||
`undefined` if none matches. Same as `.filter(f)[0]` but faster. | ||
#### .lazyFilter(function(a){ ... }) | ||
@@ -258,0 +263,0 @@ |
@@ -16,5 +16,7 @@ | ||
}; | ||
var IT=function(t,f){it(JSON.stringify(t),f)}; // mocha 3 | ||
describe('Combinatorics.baseN', function () { | ||
a = 'abc'.split(''), c = Combinatorics.baseN(a); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
[ 'a', 'a', 'a' ], | ||
@@ -48,5 +50,5 @@ [ 'b', 'a', 'a' ], | ||
])); | ||
it(0+c, is_deeply(0+c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
it(a, is_deeply(c.filter(function(a){return a[0] === 'a'}),[ | ||
IT(0+c, is_deeply(0+c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(a, is_deeply(c.filter(function(a){return a[0] === 'a'}),[ | ||
[ 'a', 'a', 'a' ], | ||
@@ -67,3 +69,3 @@ [ 'a', 'b', 'a' ], | ||
}); | ||
it(a, is_deeply(c.toArray(),[ | ||
IT(a, is_deeply(c.toArray(),[ | ||
[ 'a', 'a', 'a' ], | ||
@@ -82,3 +84,3 @@ [ 'a', 'b', 'a' ], | ||
c.lazyFilter(); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
[ 'a', 'a', 'a' ], | ||
@@ -120,3 +122,3 @@ [ 'b', 'a', 'a' ], | ||
}); | ||
it(a, is_deeply(c.toArray(),[ | ||
IT(a, is_deeply(c.toArray(),[ | ||
[ 'z', 'a', 'a' ], | ||
@@ -153,3 +155,3 @@ [ 'b', 'a', 'a' ], | ||
c.lazyMap(); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
[ 'a', 'a', 'a' ], | ||
@@ -156,0 +158,0 @@ [ 'b', 'a', 'a' ], |
@@ -15,2 +15,3 @@ /* | ||
}; | ||
var IT=function(t,f){it(JSON.stringify(t),f)}; // mocha 3 | ||
@@ -21,3 +22,3 @@ describe('Combinatorics.bigCombination', function () { | ||
c = Combinatorics.bigCombination(a, 1); | ||
it([a, 1], is_deeply(c.toArray(), [ | ||
IT([a, 1], is_deeply(c.toArray(), [ | ||
["a"], | ||
@@ -30,6 +31,6 @@ ["b"], | ||
])); | ||
it(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
c = Combinatorics.bigCombination(a, 2); | ||
it([a, 2], is_deeply(c.toArray(), [ | ||
IT([a, 2], is_deeply(c.toArray(), [ | ||
["a", "b"], | ||
@@ -51,6 +52,6 @@ ["a", "c"], | ||
])); | ||
it(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
c = Combinatorics.bigCombination(a, 3); | ||
it([a, 3], is_deeply(c.toArray(), [ | ||
IT([a, 3], is_deeply(c.toArray(), [ | ||
["a", "b", "c"], | ||
@@ -77,6 +78,6 @@ ["a", "b", "d"], | ||
])); | ||
it(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
c = Combinatorics.bigCombination(a, 4); | ||
it([a, 4], is_deeply(c.toArray(), [ | ||
IT([a, 4], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d"], | ||
@@ -98,6 +99,6 @@ ["a", "b", "c", "e"], | ||
])); | ||
it(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
c = Combinatorics.bigCombination(a, 5); | ||
it([a, 5], is_deeply(c.toArray(), [ | ||
IT([a, 5], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d", "e"], | ||
@@ -110,3 +111,3 @@ ["a", "b", "c", "d", "f"], | ||
])); | ||
it([a, 5], is_deeply(c.filter(function(a){ return a[0] !== 'a'}), [ | ||
IT([a, 5], is_deeply(c.filter(function(a){ return a[0] !== 'a'}), [ | ||
["b", "c", "d", "e", "f"] | ||
@@ -119,3 +120,3 @@ ])); | ||
}); | ||
it([a, 5], is_deeply(c.toArray(), [ | ||
IT([a, 5], is_deeply(c.toArray(), [ | ||
["b", "c", "d", "e", "f"] | ||
@@ -126,3 +127,3 @@ ])); | ||
c.lazyFilter(); | ||
it([a, 5], is_deeply(c.toArray(), [ | ||
IT([a, 5], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d", "e"], | ||
@@ -137,11 +138,11 @@ ["a", "b", "c", "d", "f"], | ||
c = Combinatorics.bigCombination(a, 6); | ||
it([a, 6], is_deeply(c.toArray(), [ | ||
IT([a, 6], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d", "e", "f"] | ||
])); | ||
it(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
// Testing large value boundaries... | ||
c = Combinatorics.bigCombination(b, 1); | ||
it([b, 1], is_deeply(c.toArray(), [ | ||
IT([b, 1], is_deeply(c.toArray(), [ | ||
["a"], ["b"], ["c"], ["d"], ["e"], ["f"], | ||
@@ -155,3 +156,3 @@ ["g"], ["h"], ["i"], ["j"], ["k"], ["l"], | ||
c = Combinatorics.bigCombination(b, 32); | ||
it([b, 32], is_deeply(c.toArray(), [ | ||
IT([b, 32], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d", "e", "f", | ||
@@ -165,3 +166,3 @@ "g", "h", "i", "j", "k", "l", | ||
c = Combinatorics.bigCombination(b); | ||
it([b], is_deeply(c.toArray(), [ | ||
IT([b], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d", "e", "f", | ||
@@ -182,3 +183,3 @@ "g", "h", "i", "j", "k", "l", | ||
}); | ||
it([a, 5], is_deeply(c.toArray(), [ | ||
IT([a, 5], is_deeply(c.toArray(), [ | ||
["z", "b", "c", "d", "e"], | ||
@@ -194,3 +195,3 @@ ["z", "b", "c", "d", "f"], | ||
c.lazyMap(); | ||
it([a, 5], is_deeply(c.toArray(), [ | ||
IT([a, 5], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d", "e"], | ||
@@ -197,0 +198,0 @@ ["a", "b", "c", "d", "f"], |
@@ -15,6 +15,8 @@ /* | ||
}; | ||
var IT=function(t,f){it(JSON.stringify(t),f)}; // mocha 3 | ||
describe('Combinatorics.cartesianProduct', function () { | ||
var c = Combinatorics.cartesianProduct( | ||
[0, 1, 2], [0, 10, 20], [0, 100, 200]); | ||
it(c, is_deeply(c.toArray(), [ | ||
IT(c.toArray(), is_deeply(c.toArray(), [ | ||
[0, 0, 0], | ||
@@ -48,5 +50,5 @@ [1, 0, 0], | ||
])); | ||
it(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
it(c, is_deeply(c.filter(function (a) { | ||
IT(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(c.toArray(), is_deeply(c.filter(function (a) { | ||
return a[0] === 0 | ||
@@ -70,3 +72,3 @@ }), [ | ||
}); | ||
it(c, is_deeply(c.toArray(), [ | ||
IT(c.toArray(), is_deeply(c.toArray(), [ | ||
[0, 0, 0], | ||
@@ -85,3 +87,3 @@ [0, 10, 0], | ||
c.lazyFilter(); | ||
it(c, is_deeply(c.toArray(), [ | ||
IT(c.toArray(), is_deeply(c.toArray(), [ | ||
[0, 0, 0], | ||
@@ -124,3 +126,3 @@ [1, 0, 0], | ||
}); | ||
it(c, is_deeply(c.toArray(), [ | ||
IT(c.toArray(), is_deeply(c.toArray(), [ | ||
[0, 0, 0], | ||
@@ -157,3 +159,3 @@ [1, 0, 0], | ||
c.lazyMap(); | ||
it(c, is_deeply(c.toArray(), [ | ||
IT(c.toArray(), is_deeply(c.toArray(), [ | ||
[0, 0, 0], | ||
@@ -160,0 +162,0 @@ [1, 0, 0], |
@@ -15,2 +15,3 @@ /* | ||
}; | ||
var IT=function(t,f){it(JSON.stringify(t),f)}; // mocha 3 | ||
@@ -20,3 +21,3 @@ describe('Combinatorics.combination', function () { | ||
c = Combinatorics.combination(a, 1); | ||
it([a, 1], is_deeply(c.toArray(), [ | ||
IT([a, 1], is_deeply(c.toArray(), [ | ||
["a"], | ||
@@ -29,6 +30,6 @@ ["b"], | ||
])); | ||
it(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
c = Combinatorics.combination(a, 2); | ||
it([a, 2], is_deeply(c.toArray(), [ | ||
IT([a, 2], is_deeply(c.toArray(), [ | ||
["a", "b"], | ||
@@ -50,6 +51,6 @@ ["a", "c"], | ||
])); | ||
it(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
c = Combinatorics.combination(a, 3); | ||
it([a, 3], is_deeply(c.toArray(), [ | ||
IT([a, 3], is_deeply(c.toArray(), [ | ||
["a", "b", "c"], | ||
@@ -76,6 +77,6 @@ ["a", "b", "d"], | ||
])); | ||
it(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
c = Combinatorics.combination(a, 4); | ||
it([a, 4], is_deeply(c.toArray(), [ | ||
IT([a, 4], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d"], | ||
@@ -97,6 +98,6 @@ ["a", "b", "c", "e"], | ||
])); | ||
it(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
c = Combinatorics.combination(a, 5); | ||
it([a, 5], is_deeply(c.toArray(), [ | ||
IT([a, 5], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d", "e"], | ||
@@ -109,3 +110,3 @@ ["a", "b", "c", "d", "f"], | ||
])); | ||
it([a, 5], is_deeply(c.filter(function(a){ return a[0] !== 'a'}), [ | ||
IT([a, 5], is_deeply(c.filter(function(a){ return a[0] !== 'a'}), [ | ||
["b", "c", "d", "e", "f"] | ||
@@ -118,3 +119,3 @@ ])); | ||
}); | ||
it([a, 5], is_deeply(c.toArray(), [ | ||
IT([a, 5], is_deeply(c.toArray(), [ | ||
["b", "c", "d", "e", "f"] | ||
@@ -125,3 +126,3 @@ ])); | ||
c.lazyFilter(); | ||
it([a, 5], is_deeply(c.toArray(), [ | ||
IT([a, 5], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d", "e"], | ||
@@ -136,7 +137,7 @@ ["a", "b", "c", "d", "f"], | ||
c = Combinatorics.combination(a, 6); | ||
it([a, 6], is_deeply(c.toArray(), [ | ||
IT([a, 6], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d", "e", "f"] | ||
])); | ||
it(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(0 + c, is_deeply(0 + c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
@@ -150,3 +151,3 @@ // Testing lazy map | ||
}); | ||
it([a, 5], is_deeply(c.toArray(), [ | ||
IT([a, 5], is_deeply(c.toArray(), [ | ||
["z", "b", "c", "d", "e"], | ||
@@ -162,3 +163,3 @@ ["z", "b", "c", "d", "f"], | ||
c.lazyMap(); | ||
it([a, 5], is_deeply(c.toArray(), [ | ||
IT([a, 5], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d", "e"], | ||
@@ -165,0 +166,0 @@ ["a", "b", "c", "d", "f"], |
@@ -15,2 +15,3 @@ /* | ||
}; | ||
var IT=function(t,f){it(JSON.stringify(t),f)}; // mocha 3 | ||
@@ -20,3 +21,3 @@ describe('Combinatorics.permutation', function () { | ||
c = Combinatorics.permutation(a, 1); | ||
it([a, 1], is_deeply(c.toArray(), [ | ||
IT([a, 1], is_deeply(c.toArray(), [ | ||
["a"], | ||
@@ -27,6 +28,6 @@ ["b"], | ||
])); | ||
it(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
c = Combinatorics.permutation(a, 2); | ||
it([a, 2], is_deeply(c.toArray(), [ | ||
IT([a, 2], is_deeply(c.toArray(), [ | ||
["a", "b"], | ||
@@ -45,3 +46,3 @@ ["b", "a"], | ||
])); | ||
it([a, 2], is_deeply(c.filter(function(a){ return a[0] === 'a'}), [ | ||
IT([a, 2], is_deeply(c.filter(function(a){ return a[0] === 'a'}), [ | ||
["a", "b"], | ||
@@ -51,4 +52,4 @@ ["a", "c"], | ||
])); | ||
it(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
@@ -59,3 +60,3 @@ // Testing lazy filter | ||
}); | ||
it([a, 2], is_deeply(c.toArray(), [ | ||
IT([a, 2], is_deeply(c.toArray(), [ | ||
["a", "b"], | ||
@@ -68,3 +69,3 @@ ["a", "c"], | ||
c.lazyFilter(); | ||
it([a, 2], is_deeply(c.toArray(), [ | ||
IT([a, 2], is_deeply(c.toArray(), [ | ||
["a", "b"], | ||
@@ -85,3 +86,3 @@ ["b", "a"], | ||
c = Combinatorics.permutation(a, 3); | ||
it([a, 3], is_deeply(c.toArray(), [ | ||
IT([a, 3], is_deeply(c.toArray(), [ | ||
["a", "b", "c"], | ||
@@ -112,6 +113,6 @@ ["a", "c", "b"], | ||
])); | ||
it(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
c = Combinatorics.permutation(a, 4); | ||
it([a, 4], is_deeply(c.toArray(), [ | ||
IT([a, 4], is_deeply(c.toArray(), [ | ||
["a", "b", "c", "d"], | ||
@@ -142,4 +143,4 @@ ["a", "b", "d", "c"], | ||
])); | ||
it(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
@@ -153,3 +154,3 @@ // Testing lazy map | ||
}); | ||
it([a, 2], is_deeply(c.toArray(), [ | ||
IT([a, 2], is_deeply(c.toArray(), [ | ||
["z", "b"], | ||
@@ -171,3 +172,3 @@ ["b", "a"], | ||
c.lazyMap(); | ||
it([a, 2], is_deeply(c.toArray(), [ | ||
IT([a, 2], is_deeply(c.toArray(), [ | ||
["a", "b"], | ||
@@ -174,0 +175,0 @@ ["b", "a"], |
@@ -15,2 +15,3 @@ /* | ||
}; | ||
var IT=function(t,f){it(JSON.stringify(t),f)}; // mocha 3 | ||
@@ -20,10 +21,10 @@ describe('Combinatorics.permutationCombination', function () { | ||
c = Combinatorics.permutationCombination(a); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
["a"] | ||
])); | ||
it(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
a = 'ab'.split(''); | ||
c = Combinatorics.permutationCombination(a); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
["a"], | ||
@@ -34,8 +35,8 @@ ["b"], | ||
])); | ||
it(a, is_deeply(c.filter(function(a){ return a[0] === 'a'}), [ | ||
IT(a, is_deeply(c.filter(function(a){ return a[0] === 'a'}), [ | ||
["a"], | ||
["a", "b"] | ||
])); | ||
it(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
@@ -46,3 +47,3 @@ // Testing lazy filter | ||
}); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
["a"], | ||
@@ -54,3 +55,3 @@ ["a", "b"] | ||
c.lazyFilter(); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
["a"], | ||
@@ -64,3 +65,3 @@ ["b"], | ||
c = Combinatorics.permutationCombination(a); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
["a"], | ||
@@ -82,7 +83,7 @@ ["b"], | ||
])); | ||
it(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
a = 'abcd'.split(''); | ||
c = Combinatorics.permutationCombination(a); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
["a"], | ||
@@ -153,4 +154,4 @@ ["b"], | ||
])); | ||
it(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(c + 0, is_deeply(c + 0, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
@@ -166,3 +167,3 @@ | ||
}); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
["z"], | ||
@@ -176,3 +177,3 @@ ["b"], | ||
c.lazyMap(); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
["a"], | ||
@@ -179,0 +180,0 @@ ["b"], |
@@ -16,9 +16,11 @@ | ||
}; | ||
var IT=function(t,f){it(JSON.stringify(t),f)}; // mocha 3 | ||
describe('Combinatorics.power', function () { | ||
var a = [], c = Combinatorics.power(a); | ||
it(c, is_deeply(c.toArray(), [ | ||
IT(c, is_deeply(c.toArray(), [ | ||
[] | ||
])); | ||
a = 'abc'.split(''), c = Combinatorics.power(a); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
[], | ||
@@ -33,5 +35,5 @@ ["a"], | ||
])); | ||
it(0+c, is_deeply(0+c, c.toArray().length)); | ||
it(c.length, is_deeply(c.length, c.toArray().length)); | ||
it(a, is_deeply(c.filter(function(a){return a.length === 2}), | ||
IT(0+c, is_deeply(0+c, c.toArray().length)); | ||
IT(c.length, is_deeply(c.length, c.toArray().length)); | ||
IT(a, is_deeply(c.filter(function(a){return a.length === 2}), | ||
Combinatorics.combination(a,2).toArray() | ||
@@ -45,3 +47,3 @@ )); | ||
}); | ||
it(a, is_deeply(c.toArray(), | ||
IT(a, is_deeply(c.toArray(), | ||
Combinatorics.combination(a,2).toArray() | ||
@@ -52,3 +54,3 @@ )); | ||
c.lazyFilter(); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
[], | ||
@@ -71,3 +73,3 @@ ["a"], | ||
}); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
[], | ||
@@ -85,3 +87,3 @@ ["z"], | ||
c.lazyMap(); | ||
it(a, is_deeply(c.toArray(), [ | ||
IT(a, is_deeply(c.toArray(), [ | ||
[], | ||
@@ -88,0 +90,0 @@ ["a"], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
78623
19
0
0
1700
291