Skip to content

Instantly share code, notes, and snippets.

@mattbierner
Last active December 25, 2015 00:49
Show Gist options
  • Select an option

  • Save mattbierner/6891052 to your computer and use it in GitHub Desktop.

Select an option

Save mattbierner/6891052 to your computer and use it in GitHub Desktop.
Javascript placeholder currying
var _ = {};
var placeholder = function(f /*, ...*/) {
var bound = [].slice.call(arguments, 1);
return function(/*...*/) {
var indx = 0;
return f.apply(f, [].reduce.call(arguments, function(p, c) {
while (indx in bound) {
var val = bound[indx];
if (val === _)
break;
p[indx] = val;
++indx;
}
p[indx] = c;
++indx;
return p;
}, bound.slice()));
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment