1 # Example program showing that 'return-continuation-until-mark' can 'pause' a 2 # function call, returning a continuation, and that calling the continuation 3 # can 'resume' the paused function call. 4 # 5 # Expected output: 6 # 1 7 # 2 8 # 3 9 10 def main [ 11 local-scope 12 k:continuation <- call-with-continuation-mark create-yielder 13 { 14 ¦ x:num, done?:bool <- call k # should return 1 15 ¦ break-if done? 16 ¦ $print x 10/newline 17 ¦ loop 18 } 19 ] 20 21 def create-yielder -> n:num, done?:bool [ 22 local-scope 23 load-ingredients 24 n <- copy 0 25 return-continuation-until-mark 26 done?:bool <- greater-or-equal n, 3 27 n <- add n, 1 28 ]