From 615f4a970a2fa5c91766ee585a7d531b083f4bff Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 23 Sep 2017 19:30:00 -0700 Subject: 4003 --- html/tangle.mu.html | 55 ++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) (limited to 'html/tangle.mu.html') diff --git a/html/tangle.mu.html b/html/tangle.mu.html index 8f405380..f00b1093 100644 --- a/html/tangle.mu.html +++ b/html/tangle.mu.html @@ -16,6 +16,7 @@ a { color:#eeeeee; text-decoration: none; } a:hover { text-decoration: underline; } * { font-size: 12pt; font-size: 1em; } .muRecipe { color: #ff8700; } +.muControl { color: #c0a020; } .Conceal { color: #4e4e4e; } .Delimiter { color: #800080; } .Special { color: #c00000; } @@ -23,7 +24,6 @@ a:hover { text-decoration: underline; } .Comment a { color:#0000ee; text-decoration:underline; } .Constant { color: #00a0a0; } .LineNr { color: #444444; } -.muControl { color: #c0a020; } --> @@ -63,38 +63,37 @@ if ('onhashchange' in window) { 3 # We construct a factorial function with separate base and recursive cases. 4 # Compare factorial.mu. 5 # - 6 # This isn't a very tasteful example, just a simple demonstration of + 6 # This isn't a very tasteful example, just a basic demonstration of 7 # possibilities. 8 9 def factorial n:num -> result:num [ 10 local-scope 11 load-ingredients -12 { -13 ¦ <base-case> -14 } -15 <recursive-case> -16 ] -17 -18 after <base-case> [ -19 # if n=0 return 1 -20 zero?:bool <- equal n, 0 -21 break-unless zero? -22 return 1 -23 ] -24 -25 after <recursive-case> [ -26 # return n * factorial(n - 1) -27 x:num <- subtract n, 1 -28 subresult:num <- factorial x -29 result <- multiply subresult, n -30 ] -31 -32 def main [ -33 1:num <- factorial 5 -34 # trailing space in next line is to help with syntax highlighting -35 $print [result: ], 1:num, [ -36 ] -37 ] +12 <factorial-cases> +13 ] +14 +15 after <factorial-cases> [ +16 # if n=0 return 1 +17 return-unless n, 1 +18 ] +19 +20 after <factorial-cases> [ +21 # return n * factorial(n - 1) +22 { +23 ¦ break-unless n +24 ¦ x:num <- subtract n, 1 +25 ¦ subresult:num <- factorial x +26 ¦ result <- multiply subresult, n +27 ¦ return result +28 } +29 ] +30 +31 def main [ +32 1:num <- factorial 5 +33 # trailing space in next line is to help with syntax highlighting +34 $print [result: ], 1:num, [ +35 ] +36 ] -- cgit 1.4.1-2-gfad0