diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-09-07 10:37:27 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-09-07 10:37:27 -0700 |
commit | f5465e1220d73e237c51897b7d1211ec53b0dc04 (patch) | |
tree | 939ee8e57241b8515aede8106c6420e330ace75a /html/factorial.mu.html | |
parent | 5ccf2653fb7d31b013f77df4e92e964e45c54f8a (diff) | |
download | mu-f5465e1220d73e237c51897b7d1211ec53b0dc04.tar.gz |
2177
Diffstat (limited to 'html/factorial.mu.html')
-rw-r--r-- | html/factorial.mu.html | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/html/factorial.mu.html b/html/factorial.mu.html index 30cf628b..d3837c22 100644 --- a/html/factorial.mu.html +++ b/html/factorial.mu.html @@ -13,10 +13,13 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.Special { color: #ff6060; } +.muRecipe { color: #ff8700; } +.muScenario { color: #00af00; } .Comment { color: #9090ff; } -.Underlined { color: #c000c0; text-decoration: underline; } -.Identifier { color: #804000; } +.Constant { color: #00a0a0; } +.Special { color: #ff6060; } +.Delimiter { color: #a04060; } +.muControl { color: #c0a020; } --> </style> @@ -30,36 +33,36 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <pre id='vimCodeElement'> <span class="Comment"># example program: compute the factorial of 5</span> -recipe main [ - <span class="Underlined">local</span>-scope - x:number<span class="Special"> <- </span>factorial 5 - $<span class="Identifier">print</span> [result: ], x, [ -] +<span class="muRecipe">recipe</span> main [ + <span class="Constant">local-scope</span> + x:number<span class="Special"> <- </span>factorial <span class="Constant">5</span> + $print <span class="Constant">[result: ]</span>, x, <span class="Constant">[ </span> +<span class="Constant">]</span> ] -recipe factorial [ - <span class="Underlined">local</span>-scope - n:number<span class="Special"> <- </span>next-ingredient - { +<span class="muRecipe">recipe</span> factorial [ + <span class="Constant">local-scope</span> + n:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Delimiter">{</span> <span class="Comment"># if n=0 return 1</span> - zero?:boolean<span class="Special"> <- </span>equal n, 0 - break-unless zero? - reply 1 - } + zero?:boolean<span class="Special"> <- </span>equal n, <span class="Constant">0</span> + <span class="muControl">break-unless</span> zero? + <span class="muControl">reply</span> <span class="Constant">1</span> + <span class="Delimiter">}</span> <span class="Comment"># return n * factorial(n-1)</span> - x:number<span class="Special"> <- </span>subtract n, 1 + x:number<span class="Special"> <- </span>subtract n, <span class="Constant">1</span> subresult:number<span class="Special"> <- </span>factorial x result:number<span class="Special"> <- </span>multiply subresult, n - reply result + <span class="muControl">reply</span> result ] <span class="Comment"># unit test</span> -scenario factorial-test [ +<span class="muScenario">scenario</span> factorial-test [ run [ - 1:number<span class="Special"> <- </span>factorial 5 + <span class="Constant">1</span>:number<span class="Special"> <- </span>factorial <span class="Constant">5</span> ] memory-should-contain [ - 1<span class="Special"> <- </span>120 + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">120</span> ] ] </pre> |