Lecture overview -- Keyboard shortcut: 'u'  Previous page: Continuation Passing Style [Section] -- Keyboard shortcut: 'p'  Next page: Observations about continuation passing style -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Simulation of other Paradigms and Continuations - slide 33 : 43

Continuation Passing Style

The implicite continuation of a function is turned into an explicit parameter

Every function takes an extra parameter: A continuation which is a function of a single parameter

No function returns normally

cps1.scm
A function programmed in both direct style and continuation passing style.
cps2-direct.scm
Functions w, f, g and h programmed in direct style.
cps2-cps.scm
The same functions programmed in continuation passing style.
Go to exercise
A discriminant function in continuation passing style
fac-direct-cps.scm
The usual recursive factorial function - in direct and continuation passing style.
fac-tail-rec-direct-cps.scm
The tail recursive factorial function - in direct and continuation passing style.
list-length-cps.scm
The list-length function - continuation passing style - handling improper lists.
list-length-iter-cps.scm
An iterative list-length function - continuation passing style - handling improper lists.