December 2021
Beginner
840 pages
47h 29m
English
Armed with an elementary understanding of the concept of a continuation and how to capture a continuation in Scheme, we present some practical examples of first-class continuations. While continuations are used for a variety of purposes in these examples, all of these examples use call/cc for global transfer of control.
A common application of a first-class continuation is to program abnormal flows of control, such as a nonlocal exit from recursion without having to return through multiple layers of recursion. Consider the following recursive definition of a Scheme function product that accepts a list of numbers and returns the product of the numbers:
Read now
Unlock full access