13 ms·
The sum-of-squares isn't a continuation, rather it just loops through the squared-ints generator up to the bound. call/cc is used to allow some form control an
by valbaca 5y ago
The sum-of-squares isn't a continuation, rather it just loops through the squared-ints generator up to the bound.
call/cc is used to allow some form control and allow the loop to exit
> Before the sum-of-square function does anything, I use call/cc to capture the continuation, and assign it to the variable break. Notice that in the syntax of Scheme, this is the last step of the function. Therefore, calling break will immediately exist the function with a returned value, no matter where it is called.
- dmux 5y agoI've reread the quote you posted and think I may understand, although I'm probably misusing some terminology: since the call to call/cc is the only thing in the lambda definition, the continuation captured at that point is kind of the termination/return point of the function. If there was something after the call/cc, e.g. a (display "Done with looping") then invoking the continuation would break out of the loop and display "Done with looping."