Created
May 11, 2017 15:52
-
-
Save yeco/8e3c73bd563d39b6918d360655f93e58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var combine = function(a, min) { | |
var fn = function(n, src, got, all) { | |
if (n == 0) { | |
if (got.length > 0) { | |
all[all.length] = got; | |
} | |
return; | |
} | |
for (var j = 0; j < src.length; j++) { | |
fn(n - 1, src.slice(j + 1), got.concat([src[j]]), all); | |
} | |
return; | |
} | |
var all = []; | |
for (var i = min; i < a.length; i++) { | |
fn(i, a, [], all); | |
} | |
all.push(a); | |
return all; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment