Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

II. Lisp is Symmetry > 6.5. lambda: A Function So Important It Deserves Its Own...

Chapter 6.5. lambda: A Function So Important It Deserves Its Own Chapter

It’s impossible to overstate the importance of the lambda command in Lisp. In fact, this command is pretty much the entire reason that Lisp exists in the first place.

What lambda Does

In short, lambda lets you create a function without giving it a name. For example, let’s say we create a half function that takes a number and divides it in half. Until now, we’ve written such a function this way:

(defun half (n)
    (/ n 2))
image with no caption

It turns out that, in Lisp, functions are actually values that we can view and pass around just as if they were numbers or lists. An experienced Lisp programmer would say that functions are first-class values in Lisp. As you saw in Chapter 5, you can actually get at the function represented by the word half by using the function operator:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint