#What is the difference between Curry and Partial? This seems like a confusing topic for a lot of people. I actually had a really hard time trying to understand the difference between the two. A lot of people think they are the same thing, or that currying is just a special form of partial application.
- What is the difference between currying and partial application, stackoverflow
- Partial Function Application is not Currying
- Currying vs Partial Application
##So what is currying? When you curry a function, it returns a function that calls another function for every parameter. Currying creates a series of single parameter functions. Some code examples should clear this up.
function test(a, b, c) {
return 'a: ' + a + ', b: ' + b + ', c: ' + c;
}
var c = curry(test);
c(10)(20)(30);
// so c looks something like like:
function c(a) {
return function(b) {
return function(c) {
test(a, b, c);
}
}
}
This is different from a Partial because a partial only returns a single function instead of a chain of functions. Here is what a partial would look like.
function test(a, b, c) {
return 'a: ' + a + ', b: ' + b + ', c: ' + c;
}
var p = partial(test, 10);
p(30, 40);
// so p looks something like:
function p(b, c) {
return test(10, b, c);
}
##Conclusion I'm not sure how currying would be useful in Javascript, so I'm not going to make any attempt to write a curry method. If you want one, Functional JavaScript provides the curry method.