From 805d58c6aeeeba3e4989c0eed6781b3861e8fae0 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 25 Jan 2018 22:39:31 -0800 Subject: 4199 --- html/070table.mu.html | 85 +++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 43 deletions(-) (limited to 'html/070table.mu.html') diff --git a/html/070table.mu.html b/html/070table.mu.html index c964ec5c..f7e15164 100644 --- a/html/070table.mu.html +++ b/html/070table.mu.html @@ -15,17 +15,16 @@ body { font-size: 12pt; font-family: monospace; color: #aaaaaa; background-color a { color:#eeeeee; text-decoration: none; } a:hover { text-decoration: underline; } * { font-size: 12pt; font-size: 1em; } +.muControl { color: #c0a020; } +.muRecipe { color: #ff8700; } .muScenario { color: #00af00; } -.Conceal { color: #4e4e4e; } .LineNr { color: #444444; } -.muData { color: #ffff00; } .Delimiter { color: #800080; } -.Comment { color: #9090ff; } -.Comment a { color:#0000ee; text-decoration:underline; } .Constant { color: #00a0a0; } .Special { color: #c00000; } -.muControl { color: #c0a020; } -.muRecipe { color: #ff8700; } +.Comment { color: #9090ff; } +.Comment a { color:#0000ee; text-decoration:underline; } +.muData { color: #ffff00; } --> @@ -67,91 +66,91 @@ 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 + 10 put-index tab, 12, 34 + 11 60:num/raw, 61:bool/raw <- index tab, 12 12 ] 13 memory-should-contain [ - 14 ¦ 60 <- 34 - 15 ¦ 61 <- 1 # found + 14 60 <- 34 + 15 61 <- 1 # found 16 ] 17 ] 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] + 23 put-index tab, [abc def], 34 + 24 1:num/raw, 2:bool/raw <- index tab, [abc def] 25 ] 26 memory-should-contain [ - 27 ¦ 1 <- 34 - 28 ¦ 2 <- 1 # found + 27 1 <- 34 + 28 2 <- 1 # found 29 ] 30 ] 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] + 36 1:num/raw, 2:bool/raw <- index tab, [abc def] 37 ] 38 memory-should-contain [ - 39 ¦ 1 <- 0 - 40 ¦ 2 <- 0 # not found + 39 1 <- 0 + 40 2 <- 0 # not found 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 + 46 capacity:num + 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-inputs 59 result <- new {(table _key _value): type} - 60 data:&:@:table-row:_key:_value <- new {(table-row _key _value): type}, capacity - 61 *result <- merge 0/length, capacity, data + 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-inputs 69 hash:num <- hash key - 70 hash <- abs hash - 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 + 70 hash <- abs hash + 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 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-inputs 86 hash:num <- hash key - 87 hash <- abs hash - 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 + 87 hash <- abs hash + 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 93 empty:&:_value <- new _value:type 94 result <- copy *empty 95 found?:bool <- get x, occupied?:offset @@ -162,7 +161,7 @@ if ('onhashchange' in window) { 100 result <- get x, value:offset 101 ] 102 -103 def abs n:num -> result:num [ +103 def abs n:num -> result:num [ 104 local-scope 105 load-inputs 106 positive?:bool <- greater-or-equal n, 0 -- cgit 1.4.1-2-gfad0