One of the significant values of curried functions is the ability to combine them through functional composition. We looked at functional composition in Chapter 5, Higher-Order Functions, and Chapter 11, Decorator Design Techniques.
When we've created a curried function, we can more easily perform function composition to create a new, more complex curried function. In this case, the PyMonad package defines the * operator for composing two functions. To explain how this works, we'll define two curried functions that we can compose. First, we'll define a function that computes the product, and then we'll define a function that computes a specialized range of values.
Here's our first function, which computes the product:
import operator prod = myreduce(operator.mul)
This is based on our curried...