Transforming Functions – Currying and Partial Application
In Chapter 6, Producing Functions, we saw several ways of manipulating functions to get new versions with some changes in their functionality. In this chapter, we will go into a particular kind of transformation, a sort of factory method that lets you produce new versions of any given function.
We will be considering the following:
- Currying: A classic FP theoretical function that transforms a function with many parameters into a sequence of unary functions
- Partial application: Another time-honored FP transformation, which produces new versions of functions by fixing some of their arguments
- Partial currying (a name of my own): Can be seen as a mixture of the two previous transformations
The techniques in this chapter will provide you with a different way of producing functions from other functions. To be fair, we’ll also see that some of these techniques can be emulated, possibly with greater...