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