about summary refs log tree commit diff stats
Commit message (Expand)AuthorAgeFilesLines
...
* 3439Kartik K. Agaram2016-10-041-1/+16
* 3438Kartik K. Agaram2016-10-041-16/+3
* 3437Kartik K. Agaram2016-10-042-1/+1
* 3436Kartik K. Agaram2016-10-041-2/+5
* 3435Kartik K. Agaram2016-10-043-0/+9
* 3434Karti
# example program: constructing functions out of order
#
# We construct a factorial function with separate base and recursive cases.
# Compare factorial.mu.
#
# This isn't a very tasteful example, just a basic demonstration of
# possibilities.

def factorial n:num -> result:num [
  local-scope
  load-inputs
  <factorial-cases>
]

after <factorial-cases> [
  # if n=0 return 1
  return-unless n, 1
]

after <factorial-cases> [
  # return n * factorial(n - 1)
  {
    break-unless n
    x:num <- subtract n, 1
    subresult:num <- factorial x
    result <- multiply subresult, n
    return result
  }
]

def main [
  1:num <- factorial 5
  # trailing space3399 - Update network primitives.
Stephen Malina2016-09-182-19/+77
* 3398Kartik K. Agaram2016-09-181-6/+11
* 3397Kartik K. Agaram2016-09-1712-916/+916
* 3396Kartik K. Agaram2016-09-1724-1663/+1663
* 3395Kartik K. Agaram2016-09-1797-4600/+4668
* 3394Kartik K. Agaram2016-09-179-43/+49
* 3393Kartik K. Agaram2016-09-179-24/+22
* 3392Kartik K. Agaram2016-09-174-7/+36
* 3391 - type abbreviations everywhereKartik K. Agaram2016-09-1724-3256/+3256