Jump to content

Closures/Value capture: Difference between revisions

m
(→‎Desugared: Adding continuation-based solution.)
m (→‎Delimited Continuations: Close code tag.)
Line 1,420:
The <code>suspend<code> operator suspends the execution of the <code>sqr</code> block, causing it to return the function <code>(op f nil)</code>. The variable <code>f</code> represents the captured continuation as a function. Continuation functions take one mandatory argument. We don't need that here, hence the <code>(op f nil)</code> expression is returned: it curries the one arg continuation function <code>f</code> to a function with no arguments.
 
The loop pushes these suspended continuations into a list, and then <code>nreverse</code>-s it.
 
We then interactively call the continuations in the list.
543

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.