Skip to content

Instantly share code, notes, and snippets.

@zerobias
Created August 14, 2017 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerobias/92a48e1db12f3127c2a2b2d9893a3172 to your computer and use it in GitHub Desktop.
Save zerobias/92a48e1db12f3127c2a2b2d9893a3172 to your computer and use it in GitHub Desktop.
Flowtype curry function
//@flow
function curry2<A, B, R>(fn : (A, B) => R) : A => B => R {
return function (a : A) : B => R {
return function (b : B) : R {
return fn(a, b);
};
};
};
function curry3<A, B, C, R>(fn : (A, B, C) => R) : A => B => C => R {
return function (a : A) : B => C => R {
return function (b : B) : C => R {
return function (c : C) : R {
return fn(a, b, c);
};
};
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment