curry2<FirstParameter, SecondParameter, ReturnType> function

ReturnType Function(SecondParameter second) Function(FirstParameter first) curry2<FirstParameter, SecondParameter, ReturnType>(
  1. ReturnType function(
    1. FirstParameter first,
    2. SecondParameter second
    )
)

Converts a binary function into a unary function that returns a unary function.

Enables the use of partial application of functions. This often leads to more concise function declarations.

The generic types are in this order:

  1. Type of the first function parameter
  2. Type of the second function parameter
  3. Return type of the function
final addFunction = (int a, int b) => a + b;
final add = curry2(addFunction);

[1, 2, 3].map(add(1))  // returns [2, 3, 4]

Implementation

ReturnType Function(SecondParameter second) Function(FirstParameter first)
    curry2<FirstParameter, SecondParameter, ReturnType>(
  ReturnType Function(FirstParameter first, SecondParameter second) function,
) =>
        (FirstParameter first) =>
            (SecondParameter second) => function(first, second);