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