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/counters.mu.html | |
parent | 5ccf2653fb7d31b013f77df4e92e964e45c54f8a (diff) | |
download | mu-f5465e1220d73e237c51897b7d1211ec53b0dc04.tar.gz |
2177
Diffstat (limited to 'html/counters.mu.html')
-rw-r--r-- | html/counters.mu.html | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/html/counters.mu.html b/html/counters.mu.html index 45ca7a5d..9a02adca 100644 --- a/html/counters.mu.html +++ b/html/counters.mu.html @@ -13,10 +13,11 @@ 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; } -.Underlined { color: #c000c0; text-decoration: underline; } +.muRecipe { color: #ff8700; } .Comment { color: #9090ff; } +.Constant { color: #00a0a0; } .Special { color: #ff6060; } -.Identifier { color: #804000; } +.muControl { color: #c0a020; } --> </style> @@ -31,36 +32,36 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="Comment"># example program: maintain multiple counters with isolated lexical scopes</span> <span class="Comment"># (spaces)</span> -recipe <span class="Identifier">new</span>-counter [ - default-space:address:<span class="Identifier">array</span>:location<span class="Special"> <- </span><span class="Identifier">new</span> location:<span class="Identifier">type</span>, 30 - n:number<span class="Special"> <- </span>next-ingredient - reply default-space +<span class="muRecipe">recipe</span> new-counter [ + <span class="Constant">default-space</span>:address:array:location<span class="Special"> <- </span>new <span class="Constant">location:type</span>, <span class="Constant">30</span> + n:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="muControl">reply</span> <span class="Constant">default-space</span> ] -recipe increment-counter [ - <span class="Underlined">local</span>-scope - 0:address:<span class="Identifier">array</span>:location/names:<span class="Identifier">new</span>-counter<span class="Special"> <- </span>next-ingredient <span class="Comment"># setup outer space; it *must* come from 'new-counter'</span> - x:number<span class="Special"> <- </span>next-ingredient - n:number/space:1<span class="Special"> <- </span>add n:number/space:1, x - reply n:number/space:1 +<span class="muRecipe">recipe</span> increment-counter [ + <span class="Constant">local-scope</span> + <span class="Constant">0</span>:address:array:location/names:new-counter<span class="Special"> <- </span><span class="Constant">next-ingredient</span> <span class="Comment"># setup outer space; it *must* come from 'new-counter'</span> + x:number<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + n:number/space:<span class="Constant">1</span><span class="Special"> <- </span>add n:number/space:<span class="Constant">1</span>, x + <span class="muControl">reply</span> n:number/space:<span class="Constant">1</span> ] -recipe main [ - <span class="Underlined">local</span>-scope +<span class="muRecipe">recipe</span> main [ + <span class="Constant">local-scope</span> <span class="Comment"># counter A</span> - a:address:<span class="Identifier">array</span>:location<span class="Special"> <- </span><span class="Identifier">new</span>-counter 34 + a:address:array:location<span class="Special"> <- </span>new-counter <span class="Constant">34</span> <span class="Comment"># counter B</span> - b:address:<span class="Identifier">array</span>:location<span class="Special"> <- </span><span class="Identifier">new</span>-counter 23 + b:address:array:location<span class="Special"> <- </span>new-counter <span class="Constant">23</span> <span class="Comment"># increment both by 2 but in different ways</span> - increment-counter a, 1 - b-value:number<span class="Special"> <- </span>increment-counter b, 2 - a-value:number<span class="Special"> <- </span>increment-counter a, 1 + increment-counter a, <span class="Constant">1</span> + b-value:number<span class="Special"> <- </span>increment-counter b, <span class="Constant">2</span> + a-value:number<span class="Special"> <- </span>increment-counter a, <span class="Constant">1</span> <span class="Comment"># check results</span> - $<span class="Identifier">print</span> [Contents of counters -] + $print <span class="Constant">[Contents of counters</span> +<span class="Constant">]</span> <span class="Comment"># trailing space in next line is to help with syntax highlighting</span> - $<span class="Identifier">print</span> [a: ], a-value, [ b: ], b-value, [ -] + $print <span class="Constant">[a: ]</span>, a-value, <span class="Constant">[ b: ]</span>, b-value, <span class="Constant">[ </span> +<span class="Constant">]</span> ] </pre> </body> |