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 and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 3 - Page 33 : 43
Programming Paradigms
Simulation of other Paradigms and Continuations
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

 

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/cps1.scmA function programmed in both direct style and continuation passing style.


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/cps2-direct.scmFunctions w, f, g and h programmed in direct style.


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/cps2-cps.scmThe same functions programmed in continuation passing style.


Go to exerciseA discriminant function in continuation passing style
 

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/fac-direct-cps.scmThe usual recursive factorial function - in direct and continuation passing style.


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/fac-tail-rec-direct-cps.scmThe tail recursive factorial function - in direct and continuation passing style.


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/list-length-cps.scmThe list-length function - continuation passing style - handling improper lists.


c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/list-length-iter-cps.scmAn iterative list-length function - continuation passing style - handling improper lists.