Skip to content

Instantly share code, notes, and snippets.

@jossmac
Created August 8, 2019 07:16
Show Gist options
  • Save jossmac/89e5b12aed6765d126eac6ed10b07c48 to your computer and use it in GitHub Desktop.
Save jossmac/89e5b12aed6765d126eac6ed10b07c48 to your computer and use it in GitHub Desktop.
Fixing a number of arguments to a function, producing another function of smaller arity
const partialApply = (fn, ...fixedArgs) => {
return (...remainingArgs) => fn(...fixedArgs.concat(...remainingArgs));
};
const add = (a, b) => a + b;
const add10 = partialApply(add, 10);
console.log(add10(5)) // 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment