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