From 6c52e24e2996a77aa6297b26159003d503aef8a0 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 18 Apr 2017 11:33:33 -0700 Subject: 3830 - crosslink shape-shifting containers in html --- html/070table.mu.html | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'html/070table.mu.html') diff --git a/html/070table.mu.html b/html/070table.mu.html index 2a7ee07f..603e9997 100644 --- a/html/070table.mu.html +++ b/html/070table.mu.html @@ -67,7 +67,7 @@ if ('onhashchange' in window) { 5 6 scenario table-read-write [ 7 local-scope - 8 tab:&:table:num:num <- new-table 30 + 8 tab:&:table:num:num <- new-table 30 9 run [ 10 ¦ put-index tab, 12, 34 11 ¦ 60:num/raw, 61:bool/raw <- index tab, 12 @@ -80,7 +80,7 @@ if ('onhashchange' in window) { 18 19 scenario table-read-write-non-integer [ 20 local-scope - 21 tab:&:table:text:num <- new-table 30 + 21 tab:&:table:text:num <- new-table 30 22 run [ 23 ¦ put-index tab, [abc def], 34 24 ¦ 1:num/raw, 2:bool/raw <- index tab, [abc def] @@ -93,7 +93,7 @@ if ('onhashchange' in window) { 31 32 scenario table-read-not-found [ 33 local-scope - 34 tab:&:table:text:num <- new-table 30 + 34 tab:&:table:text:num <- new-table 30 35 run [ 36 ¦ 1:num/raw, 2:bool/raw <- index tab, [abc def] 37 ] @@ -103,29 +103,29 @@ if ('onhashchange' in window) { 41 ] 42 ] 43 - 44 container table:_key:_value [ + 44 container table:_key:_value [ 45 length:num 46 capacity:num - 47 data:&:@:table-row:_key:_value + 47 data:&:@:table-row:_key:_value 48 ] 49 - 50 container table-row:_key:_value [ + 50 container table-row:_key:_value [ 51 occupied?:bool 52 key:_key 53 value:_value 54 ] 55 - 56 def new-table capacity:num -> result:&:table:_key:_value [ + 56 def new-table capacity:num -> result:&:table:_key:_value [ 57 local-scope 58 load-ingredients 59 result <- new {(table _key _value): type} - 60 data:&:@:table-row:_key:_value <- new {(table-row _key _value): type}, capacity + 60 data:&:@:table-row:_key:_value <- new {(table-row _key _value): type}, capacity 61 *result <- merge 0/length, capacity, data 62 ] 63 64 # todo: tag results as /required so that call-sites are forbidden from ignoring them 65 # then we could handle conflicts simply by resizing the table - 66 def put-index table:&:table:_key:_value, key:_key, value:_value -> table:&:table:_key:_value [ + 66 def put-index table:&:table:_key:_value, key:_key, value:_value -> table:&:table:_key:_value [ 67 local-scope 68 load-ingredients 69 hash:num <- hash key @@ -133,16 +133,16 @@ if ('onhashchange' in window) { 71 capacity:num <- get *table, capacity:offset 72 _, hash-key:num <- divide-with-remainder hash, capacity 73 hash-key <- abs hash-key # in case hash overflows from a double into a negative integer inside 'divide-with-remainder' above - 74 table-data:&:@:table-row:_key:_value <- get *table, data:offset - 75 x:table-row:_key:_value <- index *table-data, hash-key + 74 table-data:&:@:table-row:_key:_value <- get *table, data:offset + 75 x:table-row:_key:_value <- index *table-data, hash-key 76 occupied?:bool <- get x, occupied?:offset 77 not-occupied?:bool <- not occupied?:bool 78 assert not-occupied?, [can't handle collisions yet] - 79 new-row:table-row:_key:_value <- merge 1/true, key, value + 79 new-row:table-row:_key:_value <- merge 1/true, key, value 80 *table-data <- put-index *table-data, hash-key, new-row 81 ] 82 - 83 def index table:&:table:_key:_value, key:_key -> result:_value, found?:bool [ + 83 def index table:&:table:_key:_value, key:_key -> result:_value, found?:bool [ 84 local-scope 85 load-ingredients 86 hash:num <- hash key @@ -150,8 +150,8 @@ if ('onhashchange' in window) { 88 capacity:num <- get *table, capacity:offset 89 _, hash-key:num <- divide-with-remainder hash, capacity 90 hash-key <- abs hash-key # in case hash overflows from a double into a negative integer inside 'divide-with-remainder' above - 91 table-data:&:@:table-row:_key:_value <- get *table, data:offset - 92 x:table-row:_key:_value <- index *table-data, hash-key + 91 table-data:&:@:table-row:_key:_value <- get *table, data:offset + 92 x:table-row:_key:_value <- index *table-data, hash-key 93 empty:&:_value <- new _value:type 94 result <- copy *empty 95 found?:bool <- get x, occupied?:offset -- cgit 1.4.1-2-gfad0