Lecture overview -- Keyboard shortcut: 'u'  Previous page: Capturing, storing, and applying continuations -- Keyboard shortcut: 'p'  Next page: Practical example: Length of an improper list -- 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 29 : 43
Programming Paradigms
Simulation of other Paradigms and Continuations
Use of continuations for escaping purposes

We here illustrate applications of the continuations for escaping purposes

Context C, capturing, and escape call

Value

(+ 5 
 (call/cc 
  (lambda (e)
   (* 4 (e 10)))) )
15
(cons 1 
 (call/cc
  (lambda (e)
   (cons 2 
    (cons
     3 (e 'x))))) )
(1 . x)
(define x 5)

(if (= 0 x)
    'undefined
    (call/cc 
     (lambda (e)
      (remainder 
       (* (+ x 1)
          (- x (e 111)))
       x))) )
111

Capturing and use of a continuation for escaping purposes