about summary refs log tree commit diff stats
path: root/arc
ModeNameSize
d---------.traces12326log stats plain
-rw-r--r--Readme435log stats plain blame
-rw-r--r--blocking.arc.t900log stats plain blame
-rw-r--r--buffered-stdin.mu1263log stats plain blame
-rw-r--r--callcc.mu599log stats plain blame
-rw-r--r--channel.mu1941log stats plain blame
d---------charterm268log stats plain
-rw-r--r--chessboard.arc.t12726log stats plain blame
-rw-r--r--chessboard.mu11850log stats plain blame
-rw-r--r--color-repl.mu23324log stats plain blame
-rw-r--r--counters.mu1190log stats plain blame
-rw-r--r--edit.arc.t1161log stats plain blame
-rw-r--r--edit.mu813log stats plain blame
-rw-r--r--factorial.mu629log stats plain blame
-rw-r--r--fork.mu408log stats plain blame
-rw-r--r--generic.mu898log stats plain blame
-rw-r--r--graphics.mu889log stats plain blame
-rw-r--r--highlights969log stats plain blame
-rw-r--r--load.arc775log stats plain blame
-rwxr-xr-xmu615log stats plain blame
-rw-r--r--mu.arc127823log stats plain blame
-rw-r--r--mu.arc.t171613log stats plain blame
-rw-r--r--mu.arc.t.html562366log stats plain blame
-rw-r--r--render.vim5000log stats plain blame
-rw-r--r--scratch.vim1558log stats plain blame
-rw-r--r--stdin.mu1091log stats plain blame
-rw-r--r--tangle.mu963log stats
# 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 simple demonstration of
# possibilities.

def factorial n:number -> result:number [
  local-scope
  load-ingredients
  {
    <base-case>
  }
  <recursive-case>
]

after <base-case> [
  # if n=0 return 1
  zero?:boolean <- equal n, 0
  break-unless zero?
  return 1
]

after <recursive-case> [
  # return n * factorial(n - 1)
  x:number <- subtract n, 1
  subresult:number <- factorial x
  result <- multiply subresult, n
]

def main [
  1:number <- factorial 5
  $print [result: ], 1:number, [
]
]