f is passed to call/cc (as in the last line of the example), applying the parameter (the continuation) to 2 forces execution of the program to jump to the point where call/cc was called, and causes call/cc to return the value 2. This is then printed by the display function. In the next example, call/cc is used twice: once to generate a "return" continuation as in the first example and once to suspend an iteration through a list of items: ;; [LISTOF X] -> ( -> X u 'you-fell-off-the-end) (define (generate-one-element-at-a-time lst) ;; Both internal functions are closures over lst ;; Internal variable/Function which passes the current element in a list ;; to its return argument (which is a continuation), or passes an end-of-list marker ;; if no more elements are left. On each step the function name is ;; rebound to a continuation which points back into the function body, ;; while return is rebound to whatever continuation the caller specifies. (define (control-state return) (for-each (lambda (element) (set! return (call-with-current-continuation (lambda (resume-here) ;; Grab the current continuation (set! control-state resume-here) (return element))))) ;; (return element) evaluates to next return lst) (return 'you-fell-off-the-end)) ;; (-> X u 'you-fell-off-the-end) ;; This is the actual generator, producing one item from a-list at a time. (define (generator) (call-with-current-continuation control-state)) ;; Return the generator generator) (define generate-digit (generate-one-element-at-a-time '(0 1 2))) (generate-digit) ;; 0 (generate-digit) ;; 1 (generate-digit) ;; 2 (generate-digit) ;; you-fell-off-the-end Every time the loop is about to process another item from the list, the function grabs the current continuation, and assigns it to the variable 'control-state'. This variable initially is the closure that iterates through all elements of the list. As the computation progresses, it becomes a closure that iterates through a suffix of the given list. While the use of "call/cc" is unnecessary for a linear collection, such as [LISTOF X], the code generalizes to any collection that can be traversed. Call-with-current-continuation can also express other sophisticated primitives. For example, the next sample performs cooperative multitasking using continuations: ;; Cooperative multitasking using call-with-current-continuation ;; in 25 lines of scheme ;; The list of threads waiting to run. This is a list of one ;; argument non-returning functions (continuations, mostly) ;; A continuation is a non-returning function, just like (exit), ;; in that it never gives up control to whatever called it. (define ready-list '()) ;; A non-returning function. If there