Skip to content

Instantly share code, notes, and snippets.

@kiinlam
Created March 26, 2019 03:48
Show Gist options
  • Save kiinlam/e249e54508d14aeb7aba5d14d9322b5c to your computer and use it in GitHub Desktop.
Save kiinlam/e249e54508d14aeb7aba5d14d9322b5c to your computer and use it in GitHub Desktop.
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