extra-array
Advanced tools
Comparing version 2.0.15 to 2.0.16
21
fresh.js
@@ -65,8 +65,24 @@ // PURE FUNCTIONS | ||
/** | ||
* Lists all permutations. | ||
* Lists all possible partial sequences. | ||
* @param {array} x array | ||
* @returns {Iterable} subsequence ... | ||
*/ | ||
function* subsequences(x) { | ||
if(x.length===0) { yield []; return; } | ||
var y = x.slice(0, -1); | ||
for(var s of subsequences(y)) | ||
yield s; | ||
for(var s of subsequences(y)) { | ||
s.push(x[x.length-1]); | ||
yield s; | ||
} | ||
} | ||
/** | ||
* Lists all possible arrangements. | ||
* @param {array} x array | ||
* @returns {Iterable} permutation ... | ||
*/ | ||
function* permutations(x) { | ||
if(x.length===0) yield []; | ||
if(x.length===0) { yield []; return; } | ||
for(var i=x.length-1; i>=0; i--) { | ||
@@ -231,2 +247,3 @@ var y = splice(x, i); | ||
exports.permutations = permutations; | ||
exports.subsequences = subsequences; | ||
exports.max = max; | ||
@@ -233,0 +250,0 @@ exports.min = min; |
{ | ||
"name": "extra-array", | ||
"version": "2.0.15", | ||
"version": "2.0.16", | ||
"description": "Standard utility methods for Array.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
24108
638