Path to FP - Partial function application.
April 16, 2019
Partial function application is creating functions from other function setting “default” parameters to our base function.
What this means is that, when applying the function, you do not pass in arguments for all of the parameters defined by the function, but only for some of them, leaving the remaining ones blank.
Then we partially apply
add to get a brand new function:
Also, we can do as follow:
But if we know that our brand new function will be partially applied we can define multiple argument lists!
What if there’s a function that’s already defined but we want to partially apply it? Well, first we get our function, then we curry it and finally we can partially apply it! Let’s see:
Finally, understanding this concept is really important because one application of it is: dependency injection.