Lecture overview -- Keyboard shortcut: 'u'  Previous page: Functions as first class values -- Keyboard shortcut: 'p'  Next page: Lambda expressions in Scheme -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 2 - Page 38 : 46
Functional Programming in Scheme
Expressions, Types, and Functions
Anonymous functions

A function object does not have a name, and a function object is not necessarily bound to a name

1> ((lambda(x) (+ x 1)) 3)
4

2> (define fu-lst 
  (list (lambda (x) (+ x 1)) (lambda (x) (* x 5))))

3> fu-lst
(#<procedure> #<procedure>)

4> ((second fu-lst) 6)
30

An illustration of anonymous functions. The function (lambda(x) (+ x 1)) is the function that adds one (to its parameter). It is organized in a list side by side with the function that multiplies by five. Notice in this context that none of these two functions are named. In the last interaction we apply the latter to the number 6.