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 and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 2 - Page 10 : 35
Programming Paradigms
Recursion and Higher-order Functions
The Challenge

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

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/fac-problems-1.scmA naive attempt to define a recursive function.


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/fac-problems-2.scmEquivalent to the program above.


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/fac-ok-1.scmA definition of fac with letrec.


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/fac-ok-2.scmEquivalent to the program above - notice the use of assignment.


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/fac-key-1.scmPassing 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