Lecture overview -- Keyboard shortcut: 'u'  Previous page: Recursion without define and letrec [Section] -- Keyboard shortcut: 'p'  Next page: Development of the Y-combinator -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Recursion and Higher-order Functions - slide 10 : 35

The Challenge

It is not straightforward to program a recursive function in Scheme - using just lambda

fac-problems-1.scm
A naive attempt to define a recursive function.
fac-problems-2.scm
Equivalent to the program above.
fac-ok-1.scm
A definition of fac with letrec.
fac-ok-2.scm
Equivalent to the program above - notice the use of assignment.
fac-key-1.scm
Passing fac to itself - the key to a solution.

We now wish to separate the factorial stuff and the self passing stuff

This involves a number of steps - each of which are simple - but the resulting self passing stuff ends up being complicated