1
2
3
4 def main [
5 local-scope
6 l:&:list:num <- copy 0
7 l <- push 3, l
8 l <- push 2, l
9 l <- push 1, l
10 k:continuation, x:num, done?:bool <- call-with-continuation-mark create-yielder, l
11 {
12 ¦ break-if done?
13 ¦ $print x 10/newline
14 ¦ k, x:num, done?:bool <- call k
15 ¦ loop
16 }
17 ]
18
19 def create-yielder l:&:list:num -> n:num, done?:bool [
20 local-scope
21 load-ingredients
22 {
23 ¦ done? <- equal l, 0
24 ¦ break-if done?
25 ¦ n <- first l
26 ¦ l <- rest l
27 ¦ return-continuation-until-mark n, done?
28 ¦ loop
29 }
30
31
32
33 return-continuation-until-mark -1, done?
34 assert 0/false, [called too many times, ran out of continuations to return]
35 ]