Play audio slide show -- Keyboard shortcut: 'x'  Lecture overview -- Keyboard shortcut: 'u'  Previous page: Lambda calculus -- Keyboard shortcut: 'p'  Next page: Function objects -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Alphabetic index  Help page about these notes  Course home      Expressions, Types, and Functions - slide 35 : 46

Functions in Scheme

Functions are represented as lambda expressions in a source program

At run time, functions are represented as first class function objects

> (define x 6)

> (lambda (x) (+ x 1))
#<procedure>

> (define inc (lambda (x) (+ x 1)))

> inc
#<procedure:inc>

> (if (even? x) inc fac)
#<procedure:inc>

> ((if (even? x) inc fac) 5)
6