Skip to content

Instantly share code, notes, and snippets.

@st98
Last active August 29, 2015 14:00
Show Gist options
  • Save st98/11378840 to your computer and use it in GitHub Desktop.
Save st98/11378840 to your computer and use it in GitHub Desktop.
部分適用?
var add = function (x, y) {
return x + y;
};
var add5 = partial(add, 5);
add5(10); // => 15
// 素直に Function#bind を使いましょう
var add5 = add.bind(null, 5);
add5(10); // => 15
var partial = (function () {
var slice = [].slice;
return function (f) {
var args = slice.call(arguments, 1);
return function () {
var fargs = slice.call(arguments);
return f.apply(this, args.concat(fargs));
};
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment