about summary refs log tree commit diff stats
path: root/html/080display.cc.html
Commit message (Collapse)AuthorAgeFilesLines
* 3174Kartik K. Agaram2016-08-121-3/+19
|
* 3158Kartik K. Agaram2016-07-271-2/+2
|
* 2996Kartik K. Agaram2016-05-211-7/+7
|
* 2812Kartik K. Agaram2016-03-271-21/+30
|
* 2744Kartik K. Agaram2016-03-091-3/+3
| | | | Tweak colors and font-sizes in generated html.
* 2743Kartik K. Agaram2016-03-091-135/+127
| | | | | Looks like "TOhtml | <other command>" doesn't work on Mac OS X for some reason..
* 2706 - update htmlKartik K. Agaram2016-02-251-2/+2
|
* 2605Kartik K. Agaram2016-01-261-2/+0
|
* 2545Kartik K. Agaram2015-12-151-1/+6
| | | | update html
* 2430 - make room for more transformsKartik K. Agaram2015-11-131-0/+534
riable.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: compute the factorial of 7

recipe main [
  default-space:address:space <- new location:type, 30:literal
  x:integer <- factorial 7:literal
  $print x:integer
  $print [
]
]

recipe factorial [
  default-space:address:array:location <- new location:type, 30:literal
  n:integer <- next-ingredient
  {
    # if n=0 return 1
    zero?:boolean <- equal n:integer, 0:literal
    break-unless zero?:boolean
    reply 1:literal
  }
  # return n * factorial(n - 1)
  x:integer <- subtract n:integer, 1:literal
  subresult:integer <- factorial x:integer
  result:integer <- multiply subresult:integer, n:integer
  reply result:integer
]

# unit test
scenario factorial-test [
  run [
    1:integer <- factorial 5:literal
  ]
  memory should contain [
    1 <- 120
  ]
]