Skip to content

Instantly share code, notes, and snippets.

@dcollien
Created November 13, 2018 13:00
Show Gist options
  • Save dcollien/6f4f21f1d023cd4e6657a8b19771c215 to your computer and use it in GitHub Desktop.
Save dcollien/6f4f21f1d023cd4e6657a8b19771c215 to your computer and use it in GitHub Desktop.
const uncurry = (fn) => (...args) => args.reduce((fn, arg) => fn(arg), fn);
const curry = (fn) => {
const collect = (args, arg) => {
const collected = args.concat([arg]);
return (
collected.length >= fn.length
? fn.apply(null, collected)
: collect.bind(null, collected)
);
};
return collect.bind(null, []);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment