Can't understand example using continuations
Posted
by
Matt Fenwick
on Programmers
See other posts from Programmers
or by Matt Fenwick
Published on 2012-07-03T13:50:47Z
Indexed on
2012/07/03
15:24 UTC
Read the original article
Hit count: 332
Scheme
|continuation
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.
© Programmers or respective owner