1 ; To demonstrate tangle directives, we'll construct a factorial function with
2 ; separate base and recursive cases. Compare factorial.mu.
3 ; This isn't a very realistic example, just a simple demonstration of
7 (default-space:space-address <- new space:literal 30:literal)
8 (n:integer <- next-input)
17 (zero?:boolean <- equal n:integer 0:literal)
18 (break-unless zero?:boolean)
22 (after recursive-case [
23 ; return n*factorial(n-1)
24 (x:integer <- subtract n:integer 1:literal)
25 (subresult:integer <- factorial x:integer)
26 (result:integer <- multiply subresult:integer n:integer)
27 (reply result:integer)
31 (1:integer <- factorial 5:literal)
32 ($print (("result: " literal)))
33 (print-integer nil:literal/terminal 1:integer)
34 (print-character nil:literal/terminal ((#\newline literal)))