Higher-Order Programming

One common stumbling block for programmers learning to write programs in the functional style is that they find it hard to combine different chunks of code to perform a single action. This is called code composition. A programming language should make code composition easy. In other words, it should make it easy for you to take different pieces of code and use them together to solve a task. The most powerful tool for code composition when writing functional code is higher-order programming, which lets you use functions that accept other functions as parameters.

Let’s look at an example to understand why code composition can be a challenge to a beginning functional programmer. Suppose we want to add two to every number in ...

Get Land of Lisp now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.