Created
August 14, 2017 20:41
-
-
Save zerobias/92a48e1db12f3127c2a2b2d9893a3172 to your computer and use it in GitHub Desktop.
Flowtype curry function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@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