Question

I'm reading the r6rs Scheme report and am confused by the explanation of continuations (I find it to be too dense and lacking of examples for a beginner).

What is this code doing and how does it evaluate to 4? Why does call/cc want an argument that's a function of one argument? How is call/cc's argument used?

(+ 1 (call-with-current-continuation
       (lambda (escape)
         (+ 2 (escape 3)))))
          =⇒ 4

This example is from section 1.11 - Continuations.

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top