Skip to content

Instantly share code, notes, and snippets.

@pygy
Created January 10, 2016 22:00
Show Gist options
  • Save pygy/c39202cc7a54dc94829b to your computer and use it in GitHub Desktop.
Save pygy/c39202cc7a54dc94829b to your computer and use it in GitHub Desktop.
function innerCurry(f, args, context) {
return f.bind.apply(f, [context].concat([].slice.call(args)))
}
function add(a, b, c) {
if (arguments.length < 3) return innerCurry(add, arguments)
return a + b + c
}
add(1).lenght === 2
add(1)(2)(3) === 6
add(1, 2)(3) // likewise
add(1)(2, 3) // ditto
add(1, 2, 3) // as expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment