Closures/Value capture: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 2,090: | Line 2,090: | ||
Whenever we call a continuation, the <code>(block sqr ...)</code> environment is restored. and the suspended computation inside the block resumes by returning out of the <code>(suspend ...)</code> form normally. The block then executes to completion, returning the <code>(* cap cap)</code> form's value. At that point, our call to the continuation terminates, yielding that value. |
Whenever we call a continuation, the <code>(block sqr ...)</code> environment is restored. and the suspended computation inside the block resumes by returning out of the <code>(suspend ...)</code> form normally. The block then executes to completion, returning the <code>(* cap cap)</code> form's value. At that point, our call to the continuation terminates, yielding that value. |
||
=={{header|Yabasic}}== |
|||
<lang Yabasic> |
|||
dim funcs$(10) |
|||
sub power2(i) |
|||
return i * i |
|||
end sub |
|||
for i = 1 to 10 |
|||
funcs$(i) = "power2" |
|||
next |
|||
for i = 1 to 10 |
|||
print execute(funcs$(i), i) |
|||
next |
|||
</lang> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |