1 ; To demonstrate generic functions, we'll construct a factorial function with
2 ; separate base and recursive clauses. Compare factorial.mu.
4 ; factorial n = n*factorial(n-1)
6 (default-space:space-address <- new space:literal 30:literal)
7 (n:integer <- input 0:literal)
8 (x:integer <- subtract n:integer 1:literal)
9 (subresult:integer <- factorial x:integer)
10 (result:integer <- multiply subresult:integer n:integer)
11 (reply result:integer)
16 (default-space:space-address <- new space:literal 30:literal)
17 (n:integer <- input 0:literal)
19 (zero?:boolean <- equal n:integer 0:literal)
20 (break-unless zero?:boolean)
26 (1:integer <- factorial 5:literal)
27 ($print (("result: " literal)))
28 (print-integer nil:literal/terminal 1:integer)
29 ($print (("\n" literal)))