Chapter 5. Higher-Order Functions
A very important feature of the functional programming paradigm is higher-order functions. These are functions that accept functions as arguments or return functions as results. Python offers several kinds of higher-order functions. We'll look at them and some logical extensions.
As we can see, there are three varieties of higher-order functions as follows:
- Functions that accept functions as one (or more) of their arguments
- Functions that return a function
- Functions that accept a function and return a function, a combination of the preceding two features
Python offers several higher-order functions of the first variety. We'll look at these built-in higher-order functions in this chapter. We'll look at a few of the library modules that offer higher-order functions in later chapters.
The idea of a function that emits functions can seem a bit odd. However, when we look at a Callable
class, the class definition is a function that returns Callable
objects when evaluated...