Skip to content

Instantly share code, notes, and snippets.

@RStankov
Created October 30, 2010 21:33
Show Gist options
  • Save RStankov/655766 to your computer and use it in GitHub Desktop.
Save RStankov/655766 to your computer and use it in GitHub Desktop.
function combinator(){
var args = $A(arguments).reverse().map(function(v){ return v.split("") });
function combine(len){
if (len == 0){
return args[len];
}
return combine(len-1).inject([], function(memo, a){
args[len].each(function(b){
memo.push(b + a);
});
return memo;
});
}
return combine(args.length-1).sort();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment