about summary refs log tree commit diff stats
path: root/029tools.cc
Commit message (Expand)AuthorAgeFilesLines
* 5001 - drop the :(scenario) DSLKartik Agaram2019-03-121-21/+42
* 4993Kartik Agaram2019-03-031-1/+4
* 4987 - support `browse_trace` tool in SubXKartik Agaram2019-02-251-16/+2
* 4418Kartik Agaram2018-07-261-1/+1
* 4264Kartik Agaram2018-06-171-0/+316
* 4259Kartik Agaram2018-06-161-316/+0
* 4139Kartik K. Agaram2017-12-051-5/+1
* 4138Kartik K. Agaram2017-12-051-1/+1
* 3877Kartik K. Agaram2017-05-261-1/+1
* 3694Kartik K. Agaram2016-11-261-37/+0
* 3691Kartik K. Agaram2016-11-251-3/+3
* 3671 - support text in '$print'Kartik K. Agaram2016-11-121-0/+1
* 3669Kartik K. Agaram2016-11-111-5/+5
* 3561Kartik K. Agaram2016-10-221-6/+6
* 3522Kartik K. Agaram2016-10-191-6/+6
* 3380Kartik K. Agaram2016-09-171-2/+2
* 3374Kartik K. Agaram2016-09-161-3/+3
* 3163Kartik K. Agaram2016-08-091-3/+7
* 3120Kartik K. Agaram2016-07-211-2/+2
* 3101 - purge .traces/ dir from repo historyKartik K. Agaram2016-07-051-2/+2
* 2998Kartik K. Agaram2016-05-241-3/+7
* 2990Kartik K. Agaram2016-05-201-6/+6
* 2954 - bugfix: $systemKartik K. Agaram2016-05-111-1/+4
* 2932Kartik K. Agaram2016-05-061-1/+1
* 2850Kartik K. Agaram2016-04-201-0/+18
* 2803Kartik K. Agaram2016-03-211-2/+2
* 2773 - switch to 'int'Kartik K. Agaram2016-03-131-6/+6
* 2735 - define recipes using 'def'Kartik K. Agaram2016-03-081-5/+5
* 2712Kartik K. Agaram2016-02-261-8/+8
* 2704 - eradicate all mention of warnings from coreKartik K. Agaram2016-02-251-2/+0
* 2685Kartik K. Agaram2016-02-191-2/+2
* 2623 - bugfix: editing sandboxesKartik K. Agaram2016-02-011-1/+1
* three bugs fixedKartik K. Agaram2015-12-151-0/+26
* 2490Kartik K. Agaram2015-11-281-1/+1
* 2475 - allow addresses to be converted to numbersKartik K. Agaram2015-11-271-2/+1
* 2445 - dispatch between shape-shifting variantsKartik K. Agaram2015-11-151-0/+1
* 2377 - stop using operator[] in mapKartik K. Agaram2015-11-061-20/+20
* 2347Kartik K. Agaram2015-11-021-0/+2
* 2313Kartik K. Agaram2015-10-291-2/+2
* 2272Kartik K. Agaram2015-10-191-2/+18
* 2271 - bugfix: traces cross-contaminating errorsKartik K. Agaram2015-10-191-1/+1
* 2260 - start tracing by depth rather than labelKartik K. Agaram2015-10-061-7/+6
* 2258 - separate warnings from errorsKartik K. Agaram2015-10-061-21/+21
* 2253 - start reorganizing tracesKartik K. Agaram2015-10-051-31/+0
* 2232Kartik K. Agaram2015-10-011-0/+44
* 2226 - standardize warning formatKartik K. Agaram2015-10-011-7/+7
* 2225Kartik K. Agaram2015-10-011-18/+30
* 2199 - stop printing numbers in scientific notationKartik K. Agaram2015-09-141-2/+2
* 2095Kartik K. Agaram2015-08-281-1/+0
* 2079Kartik K. Agaram2015-08-261-20/+0
hlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Example program showing 'return-continuation-until-mark' return other values
# alongside continuations.
#
# Print out a given list of numbers.
#
# To run:
#   $ git clone https://github.com/akkartik/mu
#   $ cd mu
#   $ ./mu continuation4.mu
#
# Expected output:
#   1
#   2
#   3

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

def create-yielder l:&:list:num -> n:num, done?:bool [
  local-scope
  load-inputs
  {
    done? <- equal l, null
    break-if done?
    n <- first l
    l <- rest l
    return-continuation-until-mark 100/mark, n, done?
    loop
  }
  # A function that returns continuations shouldn't get the opportunity to
  # return. Calling functions should stop calling its continuation after this
  # point.
  return-continuation-until-mark 100/mark, -1, done?
  assert false, [called too many times, ran out of continuations to return]
]