diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-31 22:00:07 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-31 22:00:07 -0700 |
commit | 1167f8779c2de268a074fc8656f022721df56c3f (patch) | |
tree | 247b1212502916f69439038d4862f698c14b1ca5 | |
parent | cdb9fbee922225a4b2db37cb9470403e45a569b7 (diff) | |
download | mu-1167f8779c2de268a074fc8656f022721df56c3f.tar.gz |
3617
-rw-r--r-- | html/070table.mu.html | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/html/070table.mu.html b/html/070table.mu.html index 61e1466b..7d46ec53 100644 --- a/html/070table.mu.html +++ b/html/070table.mu.html @@ -62,10 +62,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muData">container</span> table:_key:_value [ length:num capacity:num - data:&:@:table_row:_key:_value + data:&:@:table-row:_key:_value ] -<span class="muData">container</span> table_row:_key:_value [ +<span class="muData">container</span> table-row:_key:_value [ occupied?:bool key:_key value:_value @@ -75,7 +75,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> result <span class="Special"><-</span> new <span class="Delimiter">{</span>(table _key _value): type<span class="Delimiter">}</span> - data:&:@:table_row:_key:_value <span class="Special"><-</span> new <span class="Delimiter">{</span>(table_row _key _value): type<span class="Delimiter">}</span>, capacity + data:&:@:table-row:_key:_value <span class="Special"><-</span> new <span class="Delimiter">{</span>(table-row _key _value): type<span class="Delimiter">}</span>, capacity *result <span class="Special"><-</span> merge <span class="Constant">0/length</span>, capacity, data ] @@ -85,23 +85,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color hash:num <span class="Special"><-</span> hash key hash <span class="Special"><-</span> abs hash capacity:num <span class="Special"><-</span> get *table, <span class="Constant">capacity:offset</span> - _, hash <span class="Special"><-</span> divide-with-remainder hash, capacity - hash <span class="Special"><-</span> abs hash <span class="Comment"># in case hash overflows into a negative integer</span> - table-data:&:@:table_row:_key:_value <span class="Special"><-</span> get *table, <span class="Constant">data:offset</span> - x:table_row:_key:_value <span class="Special"><-</span> index *table-data, hash + _, hash-key:num <span class="Special"><-</span> divide-with-remainder hash, capacity + hash-key <span class="Special"><-</span> abs hash-key <span class="Comment"># in case hash-key overflows into a negative integer</span> + table-data:&:@:table-row:_key:_value <span class="Special"><-</span> get *table, <span class="Constant">data:offset</span> + x:table-row:_key:_value <span class="Special"><-</span> index *table-data, hash-key occupied?:bool <span class="Special"><-</span> get x, <span class="Constant">occupied?:offset</span> not-occupied?:bool <span class="Special"><-</span> not occupied?:bool assert not-occupied?, <span class="Constant">[can't handle collisions yet]</span> - new-row:table_row:_key:_value <span class="Special"><-</span> merge <span class="Constant">1/true</span>, key, value - *table-data <span class="Special"><-</span> put-index *table-data, hash, new-row -] - -<span class="muRecipe">def</span> abs n:num<span class="muRecipe"> -> </span>result:num [ - <span class="Constant">local-scope</span> - <span class="Constant">load-ingredients</span> - positive?:bool <span class="Special"><-</span> greater-or-equal n,<span class="Constant"> 0</span> - <span class="muControl">return-if</span> positive?, n - result <span class="Special"><-</span> multiply n,<span class="Constant"> -1</span> + new-row:table-row:_key:_value <span class="Special"><-</span> merge <span class="Constant">1/true</span>, key, value + *table-data <span class="Special"><-</span> put-index *table-data, hash-key, new-row ] <span class="muRecipe">def</span> index table:&:table:_key:_value, key:_key<span class="muRecipe"> -> </span>result:_value [ @@ -110,14 +102,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color hash:num <span class="Special"><-</span> hash key hash <span class="Special"><-</span> abs hash capacity:num <span class="Special"><-</span> get *table, <span class="Constant">capacity:offset</span> - _, hash <span class="Special"><-</span> divide-with-remainder hash, capacity - hash <span class="Special"><-</span> abs hash <span class="Comment"># in case hash overflows into a negative integer</span> - table-data:&:@:table_row:_key:_value <span class="Special"><-</span> get *table, <span class="Constant">data:offset</span> - x:table_row:_key:_value <span class="Special"><-</span> index *table-data, hash + _, hash-key:num <span class="Special"><-</span> divide-with-remainder hash, capacity + hash-key <span class="Special"><-</span> abs hash-key <span class="Comment"># in case hash-key overflows into a negative integer</span> + table-data:&:@:table-row:_key:_value <span class="Special"><-</span> get *table, <span class="Constant">data:offset</span> + x:table-row:_key:_value <span class="Special"><-</span> index *table-data, hash-key occupied?:bool <span class="Special"><-</span> get x, <span class="Constant">occupied?:offset</span> assert occupied?, <span class="Constant">[can't handle missing elements yet]</span> result <span class="Special"><-</span> get x, <span class="Constant">value:offset</span> ] + +<span class="muRecipe">def</span> abs n:num<span class="muRecipe"> -> </span>result:num [ + <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> + positive?:bool <span class="Special"><-</span> greater-or-equal n,<span class="Constant"> 0</span> + <span class="muControl">return-if</span> positive?, n + result <span class="Special"><-</span> multiply n,<span class="Constant"> -1</span> +] </pre> </body> </html> |