Skip to content

Instantly share code, notes, and snippets.

@hryk
Created April 13, 2010 10:00
Show Gist options
  • Save hryk/364472 to your computer and use it in GitHub Desktop.
Save hryk/364472 to your computer and use it in GitHub Desktop.
var nise_permutate = function(list, subref, length) {
nestf = function(arg, arg1) {
nestfor(list, arg, arg1);
};
for (var i=0;i<length;i++) {
subref = gen(subref);
}
nestf(subref, '');
};
var nestfor = function(ary, sub, bind){
if (typeof(bind) == 'undefined') {
bind = "";
}
for (var j=0;j<ary.length;j++) {
sub(bind+ary[j]);
}
};
var gen = function(s) {
return function(s2){ nestfor(set, s, s2);}
};
var set = [2, 1];
var main = function(str){print(str);};
var len = 2;
nise_permutate(set, main, len);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment