As a ritual, let us start with an image of hot curry! :
Breaking down a function that receives multiple arguments into a series of functions that receives part of the arguments is termed as currying a function.
Moses Schönfinkel introduced it and later was implemented by Haskell Curry, hence it's famous as curry
.
Say we have a function : f::(x, y) -> z
when curried we get curry(f) :: x -> y -> z
.
In ES6
with the help of arrow functions and spread operators we can implement curry like:
1
|
|
1
|
|
1
|
|
1
|
|
Well, now you might be thinking of curryN
or nCurry
which would be like:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
And can be used like:
1 2 3 4 5 6 7 8 |
|
Simpler example:
1 2 3 4 5 6 7 |
|
Hope you enjoyed your curry! ;)