Lecture overview -- Keyboard shortcut: 'u'  Previous page: Closures -- Keyboard shortcut: 'p'  Next page: Simple web-related functions (1) -- 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 43 : 46
Functional Programming in Scheme
Expressions, Types, and Functions
Function definition in Scheme

A function object can be bound to a name via define like any other kind of value.

But we often use a slightly different, equivalent syntax for function definitions, where the 'lambda' is implicitly specified


(define f (lambda (p1 p2) ...))

The ordinary way to bind f to the value of a lambda expressions


(define (f p1 p2) ...)

An equivalent syntactic sugaring with a more shallow parenthesis structure. Whenever Scheme identifies a list at the 'name place' in a define form, it carries out the transformation (define (f p1 p2) ...) => (define f (lambda (p1 p2) ...)) . Some Scheme programmers like the form (define (f p1 p2) ...) because the calling form (f p1 p2) is a constituent of the form (define (f p1 p2) ...)