13.2 Functional composition and currying
Some functional languages work by transforming a multi-argument function syntax into a collection of single argument functions. This process is called currying: it’s named after logician Haskell Curry, who developed the theory from earlier concepts. We’ve looked at currying in depth in Chapter 11, The Toolz Package. We’ll revisit it from the PyMonad perspective here.
Currying is a technique for transforming a multi-argument function into higher-order single argument functions. In a simple case, consider a function f(x,y) → z; given two arguments x and y; this will return some resulting value, z. We can curry the function f(x,y) into into two functions: fc1(x) → fc2(y) and fc2(y) → z. Given the first argument value, x, evaluating the function fc1(x) returns a new one-argument function, fc2(y). This second function can be given the second argument value, y, and it returns the desired result, z.
We can...