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'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home    Lecture 3 - Page 40 : 42
Functional Programming in Scheme
Name binding, Recursion, Iteration, 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