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