Skip to content

Instantly share code, notes, and snippets.

@goesang
Last active August 29, 2015 14:23
Show Gist options
  • Save goesang/b85e1aa86bebf1a1e2c5 to your computer and use it in GitHub Desktop.
Save goesang/b85e1aa86bebf1a1e2c5 to your computer and use it in GitHub Desktop.
리스트에서 부분 조합을 뽑아내는 함수.
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