1. Products

Higher-Order Functions and Currying

Our memoize() function of Chapter ??? was a function factory, building stub functions that served as replacements for other functions. The technique of using functions to build other functions is extremely powerful. In this chapter, we'll look at a technique called currying, which transforms an ordinary function into a function factory for manufacturing more functions, and other techniques for transforming one function into another.

A higher-order function is a function that operates on other functions instead of on data values. Some of these take data arguments and manufacture functions to order; others, like the imap() function of imap, transform one function into another one.