Closures/Value capture: Difference between revisions
Content added Content deleted
m (→Delimited Continuations: Close code tag.) |
m (→Delimited Continuations: Close code tag again.) |
||
Line 1,418: | Line 1,418: | ||
49</pre> |
49</pre> |
||
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 <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. |
The loop pushes these suspended continuations into a list, and then <code>nreverse</code>-s it. |