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 #<procedure:add1>
When we enter ...
Get Realm of Racket now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.