https://github.com/akkartik/mu/blob/master/continuation2.mu
1
2
3
4
5
6
7
8
9
10
11
12
13
14 def main [
15 local-scope
16 l:&:list:num <- copy null
17 l <- push 3, l
18 l <- push 2, l
19 l <- push 1, l
20 k:continuation <- call-with-continuation-mark 100/mark, create-yielder, l
21 {
22 x:num, done?:bool <- call k
23 break-if done?
24 $print x 10/newline
25 loop
26 }
27 ]
28
29 def create-yielder l:&:list:num -> n:num, done?:bool [
30 local-scope
31 load-inputs
32 return-continuation-until-mark 100/mark
33 done? <- equal l, null
34 return-if done?, 0/dummy
35 n <- first l
36 l <- rest l
37 ]