ABSTRACT

In chapter 11, you’ll learn about function operators. A function operator is a function that takes one (or more) functions as input and returns a function as output.

Function operators are closely related to function factories; indeed they’re just a function factory that takes a function as input. Like factories, there’s nothing you can’t do without them, but they often allow you to factor out complexity in order to make your code more readable and reusable. Function operators are typically paired with functionals. If you’re using a for-loop, there’s rarely a reason to use a function operator, as it will make your code more complex for little gain. If you’re familiar with Python, decorators is just another name for function operators.

“Existing function operators” introduces you to two extremely useful existing function operators, and shows you how to use them to solve real problems. “Case study: Creating your own function operators” works through a problem amenable to solution with function operators: downloading many web pages.