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