Created
October 30, 2010 21:33
-
-
Save RStankov/655766 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 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