about summary refs log tree commit diff stats
path: root/html/091run_interactive.cc.html
Commit message (Expand)AuthorAgeFilesLines
* 2996Kartik K. Agaram2016-05-211-5/+5
* 2866Kartik K. Agaram2016-04-251-28/+28
* 2812Kartik K. Agaram2016-03-271-122/+107
* 2745Kartik K. Agaram2016-03-091-1/+1
* 2744Kartik K. Agaram2016-03-091-3/+3
* 2743Kartik K. Agaram2016-03-091-119/+111
* 2710Kartik K. Agaram2016-02-251-9/+1
* 2706 - update htmlKartik K. Agaram2016-02-251-24/+23
* 2605Kartik K. Agaram2016-01-261-32/+31
* 2545Kartik K. Agaram2015-12-151-13/+79
* 2611Kartik K. Agaram2015-11-291-6/+30
* 2447Kartik K. Agaram2015-11-151-2/+1
* 2430 - make room for more transformsKartik K. Agaram2015-11-131-0/+489
29 30
31
32
33
34
35
36
37


                                                                       




                                              



                  

















                                                                 
             
                                

                          


              
# Example program showing that a 'paused' continuation can be 'resumed'
# multiple times from the same point (but with changes to data).
#
# To run:
#   $ git clone https://github.com/akkartik/mu
#   $ cd mu
#   $ ./mu continuation2.mu
#
# Expected output:
#   1
#   2
#   3

def main [
  local-scope
  l:&:list:num <- copy 0
  l <- push 3, l
  l <- push 2, l
  l <- push 1, l
  k:continuation <- call-with-continuation-mark create-yielder, l
  {
    x:num, done?:bool <- call k
    break-if done?
    $print x 10/newline
    loop
  }
]

def create-yielder l:&:list:num -> n:num, done?:bool [
  local-scope
  load-inputs
  return-continuation-until-mark
  done? <- equal l, 0/nil
  return-if done?, 0/false
  n <- first l
  l <- rest l
]