Function: curry

core.lambda.curry(n, f)
Returns:A curried version of f, up to n arguments.
ₙ:Number → (α₁, α₂, ..., αₙ → β) → (α₁ → α₂ → ... → αₙ → β)

Transforms any function on tuples into a curried function.

Examples

1
2
3
4
5
6
7
function sub3(a, b, c){ return a - b - c }

curry(3, sub3)(5)(2)(1)      // => 2
curry(3, sub3)(5, 2)(1)      // => 2
curry(3, sub3)(5)(2, 1)      // => 2
curry(3, sub3)(5, 2, 1)      // => 2
curry(3, sub3)(5, 2, 1, 0)   // => TypeError: 2 is not a function