anonymous procedures
anonymous numbers
- the expression (* (+ 2 3) 4)) contains the subexpression (+ 2 3)
- we could introduced a name for the subexpression’s value instead
with (define i (+ 2 3)) and then written (* i 4)
- but it’s convenient to have anonymous values
anonymous procedures
- compare this to
(define (square i) (* i i))
(square 5)
- what if we want to make the squaring procedure anonymous?
- we can write an expression whose value is the squaring procedure like this:
- now for (square 5), we can write
is this a big deal?
- we’ll see more compelling uses of lambda later
- lambda will allow us to construct a procedure on the fly