Chapter 7. (Land of Lambda)


Are you tired of writing the same kind of functions over and over again? Is the list empty? Do this. Is the list non-empty? Do that. Don’t forget to recur. In this chapter, we will show you how to abstract and use lambda, something you probably didn’t see in your introductory programming courses. Al—whom you surely remember from the introduction—invented it in the 1930s, and Lisp has had it for 50 years or more. This chapter is all about lambda and its tricks.


7.1 Functions as Values

Before we can begin to work with lambda, we need to discuss one key concept about functions in Racket. Functions in Racket are values, just like numbers, strings, and images. Let’s look at an example:

> add1

When we enter ...

Get Realm of Racket now with O’Reilly online learning.

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