Skip to content

Instantly share code, notes, and snippets.

@webbower
Last active February 15, 2018 18:45
Show Gist options
  • Save webbower/6959e406d01081fe015ee62c4a1b467d to your computer and use it in GitHub Desktop.
Save webbower/6959e406d01081fe015ee62c4a1b467d to your computer and use it in GitHub Desktop.
const curry = (
f, arr = []
) => (...args) => (
a => a.length === f.length ?
f(...a) :
curry(f, a)
)([...arr, ...args]);
// Unbound native-friendly since you can specify arity (typicaly native.length + 1)
const curry2 = (
fn, arity = fn.length, arr = []
) => (...args) => (
a => a.length === arity ?
fn(...a) :
curry2(fn, arity, a)
)([...arr, ...args]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment