Created
March 26, 2019 03:48
-
-
Save kiinlam/e249e54508d14aeb7aba5d14d9322b5c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function combine(arr, num) { | |
var r = []; | |
(function f(t, a, n) { | |
if (n == 0) return r.push(t); | |
for (var i = 0, l = a.length; i <= l - n; i++) { | |
f(t.concat(a[i]), a.slice(i + 1), n - 1); | |
} | |
})([], arr, num); | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment