Last active
August 29, 2015 14:23
-
-
Save goesang/b85e1aa86bebf1a1e2c5 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 arr = [-1,0 ,1]; | |
function f(arr,a){ | |
console.log(a); | |
if(arr==0) | |
return; | |
for(var i = 0;i<arr.length;i++){ | |
var b = arr.slice(); | |
var tmp = [b[i]]; | |
tmp = tmp.concat(a); | |
b.splice(i,1); | |
f(b,tmp); | |
} | |
} | |
f(arr,[]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment