From b301e0c0e6b54dceecbe4ee1ef8f610411015c30 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 27 Jan 2018 00:28:51 -0800 Subject: 4200 Forgot to set up exuberant_ctags_rc as .ctags on new laptop. --- html/061text.mu.html | 160 +++++++++++++++++++++++++-------------------------- 1 file changed, 80 insertions(+), 80 deletions(-) (limited to 'html/061text.mu.html') diff --git a/html/061text.mu.html b/html/061text.mu.html index 471834ed..e8cebf0d 100644 --- a/html/061text.mu.html +++ b/html/061text.mu.html @@ -178,27 +178,27 @@ if ('onhashchange' in window) { 117 ] 118 119 # A new type to help incrementally construct texts. - 120 container buffer:_elem [ + 120 container buffer:_elem [ 121 length:num 122 data:&:@:_elem 123 ] 124 - 125 def new-buffer capacity:num -> result:&:buffer:_elem [ + 125 def new-buffer capacity:num -> result:&:buffer:_elem [ 126 local-scope 127 load-inputs 128 result <- new {(buffer _elem): type} 129 *result <- put *result, length:offset, 0 130 { - 131 break-if capacity + 131 break-if capacity 132 # capacity not provided - 133 capacity <- copy 10 + 133 capacity <- copy 10 134 } - 135 data:&:@:_elem <- new _elem:type, capacity + 135 data:&:@:_elem <- new _elem:type, capacity 136 *result <- put *result, data:offset, data 137 return result 138 ] 139 - 140 def grow-buffer buf:&:buffer:_elem -> buf:&:buffer:_elem [ + 140 def grow-buffer buf:&:buffer:_elem -> buf:&:buffer:_elem [ 141 local-scope 142 load-inputs 143 # double buffer size @@ -219,25 +219,25 @@ if ('onhashchange' in window) { 158 } 159 ] 160 - 161 def buffer-full? in:&:buffer:_elem -> result:bool [ + 161 def buffer-full? in:&:buffer:_elem -> result:bool [ 162 local-scope 163 load-inputs 164 len:num <- get *in, length:offset 165 s:&:@:_elem <- get *in, data:offset - 166 capacity:num <- length *s - 167 result <- greater-or-equal len, capacity + 166 capacity:num <- length *s + 167 result <- greater-or-equal len, capacity 168 ] 169 170 # most broadly applicable definition of append to a buffer - 171 def append buf:&:buffer:_elem, x:_elem -> buf:&:buffer:_elem [ + 171 def append buf:&:buffer:_elem, x:_elem -> buf:&:buffer:_elem [ 172 local-scope 173 load-inputs 174 len:num <- get *buf, length:offset 175 { 176 # grow buffer if necessary - 177 full?:bool <- buffer-full? buf + 177 full?:bool <- buffer-full? buf 178 break-unless full? - 179 buf <- grow-buffer buf + 179 buf <- grow-buffer buf 180 } 181 s:&:@:_elem <- get *buf, data:offset 182 *s <- put-index *s, len, x @@ -247,7 +247,7 @@ if ('onhashchange' in window) { 186 187 # most broadly applicable definition of append to a buffer of characters: just 188 # call to-text - 189 def append buf:&:buffer:char, x:_elem -> buf:&:buffer:char [ + 189 def append buf:&:buffer:char, x:_elem -> buf:&:buffer:char [ 190 local-scope 191 load-inputs 192 text:text <- to-text x @@ -255,7 +255,7 @@ if ('onhashchange' in window) { 194 ] 195 196 # specialization for characters that is backspace-aware - 197 def append buf:&:buffer:char, c:char -> buf:&:buffer:char [ + 197 def append buf:&:buffer:char, c:char -> buf:&:buffer:char [ 198 local-scope 199 load-inputs 200 len:num <- get *buf, length:offset @@ -271,9 +271,9 @@ if ('onhashchange' in window) { 210 } 211 { 212 # grow buffer if necessary - 213 full?:bool <- buffer-full? buf + 213 full?:bool <- buffer-full? buf 214 break-unless full? - 215 buf <- grow-buffer buf + 215 buf <- grow-buffer buf 216 } 217 s:text <- get *buf, data:offset 218 *s <- put-index *s, len, c @@ -281,7 +281,7 @@ if ('onhashchange' in window) { 220 *buf <- put *buf, length:offset, len 221 ] 222 - 223 def append buf:&:buffer:_elem, t:&:@:_elem -> buf:&:buffer:_elem [ + 223 def append buf:&:buffer:_elem, t:&:@:_elem -> buf:&:buffer:_elem [ 224 local-scope 225 load-inputs 226 len:num <- length *t @@ -298,7 +298,7 @@ if ('onhashchange' in window) { 237 238 scenario append-to-empty-buffer [ 239 local-scope - 240 x:&:buffer:char <- new-buffer + 240 x:&:buffer:char <- new-buffer 241 run [ 242 c:char <- copy 97/a 243 x <- append x, c @@ -316,7 +316,7 @@ if ('onhashchange' in window) { 255 256 scenario append-to-buffer [ 257 local-scope - 258 x:&:buffer:char <- new-buffer + 258 x:&:buffer:char <- new-buffer 259 c:char <- copy 97/a 260 x <- append x, c 261 run [ @@ -338,7 +338,7 @@ if ('onhashchange' in window) { 277 278 scenario append-grows-buffer [ 279 local-scope - 280 x:&:buffer:char <- new-buffer 3 + 280 x:&:buffer:char <- new-buffer 3 281 s1:text <- get *x, data:offset 282 x <- append x, [abc] # buffer is now full 283 s2:text <- get *x, data:offset @@ -375,12 +375,12 @@ if ('onhashchange' in window) { 314 315 scenario buffer-append-handles-backspace [ 316 local-scope - 317 x:&:buffer:char <- new-buffer + 317 x:&:buffer:char <- new-buffer 318 x <- append x, [ab] 319 run [ 320 c:char <- copy 8/backspace 321 x <- append x, c - 322 s:text <- buffer-to-array x + 322 s:text <- buffer-to-array x 323 10:@:char/raw <- copy *s 324 ] 325 memory-should-contain [ @@ -392,11 +392,11 @@ if ('onhashchange' in window) { 331 332 scenario append-to-buffer-of-non-characters [ 333 local-scope - 334 x:&:buffer:text <- new-buffer 1/capacity + 334 x:&:buffer:text <- new-buffer 1/capacity 335 # no errors 336 ] 337 - 338 def buffer-to-array in:&:buffer:_elem -> result:&:@:_elem [ + 338 def buffer-to-array in:&:buffer:_elem -> result:&:@:_elem [ 339 local-scope 340 load-inputs 341 # propagate null buffer @@ -416,7 +416,7 @@ if ('onhashchange' in window) { 355 } 356 ] 357 - 358 def blank? x:&:@:_elem -> result:bool [ + 358 def blank? x:&:@:_elem -> result:bool [ 359 local-scope 360 load-inputs 361 return-unless x, 1/true @@ -435,7 +435,7 @@ if ('onhashchange' in window) { 374 def append first:text -> result:text [ 375 local-scope 376 load-inputs - 377 buf:&:buffer:char <- new-buffer 30 + 377 buf:&:buffer:char <- new-buffer 30 378 # append first input 379 { 380 break-unless first @@ -449,7 +449,7 @@ if ('onhashchange' in window) { 388 buf <- append buf, arg 389 loop 390 } - 391 result <- buffer-to-array buf + 391 result <- buffer-to-array buf 392 ] 393 394 scenario text-append-1 [ @@ -509,7 +509,7 @@ if ('onhashchange' in window) { 448 local-scope 449 x:text <- new [abc] 450 run [ - 451 x <- replace x, 98/b, 122/z + 451 x <- replace x, 98/b, 122/z 452 10:@:char/raw <- copy *x 453 ] 454 memory-should-contain [ @@ -517,7 +517,7 @@ if ('onhashchange' in window) { 456 ] 457 ] 458 - 459 def replace s:text, oldc:char, newc:char, from:num/optional -> s:text [ + 459 def replace s:text, oldc:char, newc:char, from:num/optional -> s:text [ 460 local-scope 461 load-inputs 462 len:num <- length *s @@ -526,14 +526,14 @@ if ('onhashchange' in window) { 465 return-if done? 466 *s <- put-index *s, i, newc 467 i <- add i, 1 - 468 s <- replace s, oldc, newc, i + 468 s <- replace s, oldc, newc, i 469 ] 470 471 scenario replace-character-at-start [ 472 local-scope 473 x:text <- new [abc] 474 run [ - 475 x <- replace x, 97/a, 122/z + 475 x <- replace x, 97/a, 122/z 476 10:@:char/raw <- copy *x 477 ] 478 memory-should-contain [ @@ -545,7 +545,7 @@ if ('onhashchange' in window) { 484 local-scope 485 x:text <- new [abc] 486 run [ - 487 x <- replace x, 99/c, 122/z + 487 x <- replace x, 99/c, 122/z 488 10:@:char/raw <- copy *x 489 ] 490 memory-should-contain [ @@ -557,7 +557,7 @@ if ('onhashchange' in window) { 496 local-scope 497 x:text <- new [abc] 498 run [ - 499 x <- replace x, 100/d, 122/z + 499 x <- replace x, 100/d, 122/z 500 10:@:char/raw <- copy *x 501 ] 502 memory-should-contain [ @@ -569,7 +569,7 @@ if ('onhashchange' in window) { 508 local-scope 509 x:text <- new [banana] 510 run [ - 511 x <- replace x, 97/a, 122/z + 511 x <- replace x, 97/a, 122/z 512 10:@:char/raw <- copy *x 513 ] 514 memory-should-contain [ @@ -578,7 +578,7 @@ if ('onhashchange' in window) { 517 ] 518 519 # replace underscores in first with remaining args - 520 def interpolate template:text -> result:text [ + 520 def interpolate template:text -> result:text [ 521 local-scope 522 load-inputs # consume just the template 523 # compute result-len, space to allocate for result @@ -656,7 +656,7 @@ if ('onhashchange' in window) { 595 x:text <- new [abc_ghi] 596 y:text <- new [def] 597 run [ - 598 z:text <- interpolate x, y + 598 z:text <- interpolate x, y 599 10:@:char/raw <- copy *z 600 ] 601 memory-should-contain [ @@ -669,7 +669,7 @@ if ('onhashchange' in window) { 608 x:text <- new [_, hello!] 609 y:text <- new [abc] 610 run [ - 611 z:text <- interpolate x, y + 611 z:text <- interpolate x, y 612 10:@:char/raw <- copy *z 613 ] 614 memory-should-contain [ @@ -683,7 +683,7 @@ if ('onhashchange' in window) { 622 x:text <- new [hello, _] 623 y:text <- new [abc] 624 run [ - 625 z:text <- interpolate x, y + 625 z:text <- interpolate x, y 626 10:@:char/raw <- copy *z 627 ] 628 memory-should-contain [ @@ -692,7 +692,7 @@ if ('onhashchange' in window) { 631 ] 632 633 # result:bool <- space? c:char - 634 def space? c:char -> result:bool [ + 634 def space? c:char -> result:bool [ 635 local-scope 636 load-inputs 637 # most common case first @@ -753,7 +753,7 @@ if ('onhashchange' in window) { 692 result <- equal c, 12288/ideographic-space 693 ] 694 - 695 def trim s:text -> result:text [ + 695 def trim s:text -> result:text [ 696 local-scope 697 load-inputs 698 len:num <- length *s @@ -767,7 +767,7 @@ if ('onhashchange' in window) { 706 return 707 } 708 curr:char <- index *s, start - 709 whitespace?:bool <- space? curr + 709 whitespace?:bool <- space? curr 710 break-unless whitespace? 711 start <- add start, 1 712 loop @@ -778,7 +778,7 @@ if ('onhashchange' in window) { 717 not-at-start?:bool <- greater-than end, start 718 assert not-at-start?, [end ran up against start] 719 curr:char <- index *s, end - 720 whitespace?:bool <- space? curr + 720 whitespace?:bool <- space? curr 721 break-unless whitespace? 722 end <- subtract end, 1 723 loop @@ -806,7 +806,7 @@ if ('onhashchange' in window) { 745 local-scope 746 x:text <- new [abc] 747 run [ - 748 y:text <- trim x + 748 y:text <- trim x 749 1:@:char/raw <- copy *y 750 ] 751 memory-should-contain [ @@ -818,7 +818,7 @@ if ('onhashchange' in window) { 757 local-scope 758 x:text <- new [ abc] 759 run [ - 760 y:text <- trim x + 760 y:text <- trim x 761 1:@:char/raw <- copy *y 762 ] 763 memory-should-contain [ @@ -830,7 +830,7 @@ if ('onhashchange' in window) { 769 local-scope 770 x:text <- new [abc ] 771 run [ - 772 y:text <- trim x + 772 y:text <- trim x 773 1:@:char/raw <- copy *y 774 ] 775 memory-should-contain [ @@ -842,7 +842,7 @@ if ('onhashchange' in window) { 781 local-scope 782 x:text <- new [ abc ] 783 run [ - 784 y:text <- trim x + 784 y:text <- trim x 785 1:@:char/raw <- copy *y 786 ] 787 memory-should-contain [ @@ -855,7 +855,7 @@ if ('onhashchange' in window) { 794 x:text <- new [ abc 795 ] 796 run [ - 797 y:text <- trim x + 797 y:text <- trim x 798 1:@:char/raw <- copy *y 799 ] 800 memory-should-contain [ @@ -979,7 +979,7 @@ if ('onhashchange' in window) { 918 # does some unnecessary work checking even when there isn't enough of text left 919 done?:bool <- greater-or-equal idx, len 920 break-if done? - 921 found?:bool <- match-at text, pattern, idx + 921 found?:bool <- match-at text, pattern, idx 922 break-if found? 923 idx <- add idx, 1 924 # optimization: skip past indices that definitely won't match @@ -1050,7 +1050,7 @@ if ('onhashchange' in window) { 989 ] 990 991 # checks if pattern matches at index 'idx' - 992 def match-at text:text, pattern:text, idx:num -> result:bool [ + 992 def match-at text:text, pattern:text, idx:num -> result:bool [ 993 local-scope 994 load-inputs 995 pattern-len:num <- length *pattern @@ -1080,7 +1080,7 @@ if ('onhashchange' in window) { 1019 x:text <- new [abc] 1020 y:text <- new [ab] 1021 run [ -1022 10:bool/raw <- match-at x, y, 0 +1022 10:bool/raw <- match-at x, y, 0 1023 ] 1024 memory-should-contain [ 1025 10 <- 1 # match found @@ -1091,7 +1091,7 @@ if ('onhashchange' in window) { 1030 local-scope 1031 x:text <- new [abc] 1032 run [ -1033 10:bool/raw <- match-at x, x, 0 +1033 10:bool/raw <- match-at x, x, 0 1034 ] 1035 memory-should-contain [ 1036 10 <- 1 # match found @@ -1103,7 +1103,7 @@ if ('onhashchange' in window) { 1042 x:text <- new [abc] 1043 y:text <- new [a] 1044 run [ -1045 10:bool/raw <- match-at x, y, 4 +1045 10:bool/raw <- match-at x, y, 4 1046 ] 1047 memory-should-contain [ 1048 10 <- 0 # never matches @@ -1115,7 +1115,7 @@ if ('onhashchange' in window) { 1054 x:text <- new [abc] 1055 y:text <- new [] 1056 run [ -1057 10:bool/raw <- match-at x, y, 0 +1057 10:bool/raw <- match-at x, y, 0 1058 ] 1059 memory-should-contain [ 1060 10 <- 1 # always matches empty pattern given a valid index @@ -1127,7 +1127,7 @@ if ('onhashchange' in window) { 1066 x:text <- new [abc] 1067 y:text <- new [] 1068 run [ -1069 10:bool/raw <- match-at x, y, 4 +1069 10:bool/raw <- match-at x, y, 4 1070 ] 1071 memory-should-contain [ 1072 10 <- 0 # no match @@ -1139,7 +1139,7 @@ if ('onhashchange' in window) { 1078 x:text <- new [] 1079 y:text <- new [abc] 1080 run [ -1081 10:bool/raw <- match-at x, y, 0 +1081 10:bool/raw <- match-at x, y, 0 1082 ] 1083 memory-should-contain [ 1084 10 <- 0 # no match @@ -1150,7 +1150,7 @@ if ('onhashchange' in window) { 1089 local-scope 1090 x:text <- new [] 1091 run [ -1092 10:bool/raw <- match-at x, x, 0 +1092 10:bool/raw <- match-at x, x, 0 1093 ] 1094 memory-should-contain [ 1095 10 <- 1 # matches because pattern is also empty @@ -1162,7 +1162,7 @@ if ('onhashchange' in window) { 1101 x:text <- new [abc] 1102 y:text <- new [bc] 1103 run [ -1104 10:bool/raw <- match-at x, y, 1 +1104 10:bool/raw <- match-at x, y, 1 1105 ] 1106 memory-should-contain [ 1107 10 <- 1 # match @@ -1174,14 +1174,14 @@ if ('onhashchange' in window) { 1113 x:text <- new [abc] 1114 y:text <- new [bc] 1115 run [ -1116 10:bool/raw <- match-at x, y, 0 +1116 10:bool/raw <- match-at x, y, 0 1117 ] 1118 memory-should-contain [ 1119 10 <- 0 # no match 1120 ] 1121 ] 1122 -1123 def split s:text, delim:char -> result:&:@:text [ +1123 def split s:text, delim:char -> result:&:@:text [ 1124 local-scope 1125 load-inputs 1126 # empty text? return empty array @@ -1214,7 +1214,7 @@ if ('onhashchange' in window) { 1153 break-if done? 1154 end:num <- find-next s, delim, start 1155 # copy start..end into result[curr-result] -1156 dest:text <- copy-range s, start, end +1156 dest:text <- copy-range s, start, end 1157 *result <- put-index *result, curr-result, dest 1158 # slide over to next slice 1159 start <- add end, 1 @@ -1227,7 +1227,7 @@ if ('onhashchange' in window) { 1166 local-scope 1167 x:text <- new [a/b] 1168 run [ -1169 y:&:@:text <- split x, 47/slash +1169 y:&:@:text <- split x, 47/slash 1170 10:num/raw <- length *y 1171 a:text <- index *y, 0 1172 b:text <- index *y, 1 @@ -1245,7 +1245,7 @@ if ('onhashchange' in window) { 1184 local-scope 1185 x:text <- new [a/b/c] 1186 run [ -1187 y:&:@:text <- split x, 47/slash +1187 y:&:@:text <- split x, 47/slash 1188 10:num/raw <- length *y 1189 a:text <- index *y, 0 1190 b:text <- index *y, 1 @@ -1266,7 +1266,7 @@ if ('onhashchange' in window) { 1205 local-scope 1206 x:text <- new [abc] 1207 run [ -1208 y:&:@:text <- split x, 47/slash +1208 y:&:@:text <- split x, 47/slash 1209 10:num/raw <- length *y 1210 a:text <- index *y, 0 1211 20:@:char/raw <- copy *a @@ -1281,7 +1281,7 @@ if ('onhashchange' in window) { 1220 local-scope 1221 x:text <- new [] 1222 run [ -1223 y:&:@:text <- split x, 47/slash +1223 y:&:@:text <- split x, 47/slash 1224 10:num/raw <- length *y 1225 ] 1226 memory-should-contain [ @@ -1293,7 +1293,7 @@ if ('onhashchange' in window) { 1232 local-scope 1233 x:text <- new [a/b//c] 1234 run [ -1235 y:&:@:text <- split x:text, 47/slash +1235 y:&:@:text <- split x:text, 47/slash 1236 10:num/raw <- length *y 1237 a:text <- index *y, 0 1238 b:text <- index *y, 1 @@ -1313,7 +1313,7 @@ if ('onhashchange' in window) { 1252 ] 1253 ] 1254 -1255 def split-first text:text, delim:char -> x:text, y:text [ +1255 def split-first text:text, delim:char -> x:text, y:text [ 1256 local-scope 1257 load-inputs 1258 # empty text? return empty texts @@ -1326,16 +1326,16 @@ if ('onhashchange' in window) { 1265 return 1266 } 1267 idx:num <- find-next text, delim, 0 -1268 x:text <- copy-range text, 0, idx +1268 x:text <- copy-range text, 0, idx 1269 idx <- add idx, 1 -1270 y:text <- copy-range text, idx, len +1270 y:text <- copy-range text, idx, len 1271 ] 1272 1273 scenario text-split-first [ 1274 local-scope 1275 x:text <- new [a/b] 1276 run [ -1277 y:text, z:text <- split-first x, 47/slash +1277 y:text, z:text <- split-first x, 47/slash 1278 10:@:char/raw <- copy *y 1279 20:@:char/raw <- copy *z 1280 ] @@ -1345,7 +1345,7 @@ if ('onhashchange' in window) { 1284 ] 1285 ] 1286 -1287 def copy-range buf:text, start:num, end:num -> result:text [ +1287 def copy-range buf:text, start:num, end:num -> result:text [ 1288 local-scope 1289 load-inputs 1290 # if end is out of bounds, trim it @@ -1372,7 +1372,7 @@ if ('onhashchange' in window) { 1311 local-scope 1312 x:text <- new [abc] 1313 run [ -1314 y:text <- copy-range x, 1, 3 +1314 y:text <- copy-range x, 1, 3 1315 1:@:char/raw <- copy *y 1316 ] 1317 memory-should-contain [ @@ -1384,7 +1384,7 @@ if ('onhashchange' in window) { 1323 local-scope 1324 x:text <- new [abc] 1325 run [ -1326 y:text <- copy-range x, 2, 4 +1326 y:text <- copy-range x, 2, 4 1327 1:@:char/raw <- copy *y 1328 ] 1329 memory-should-contain [ @@ -1396,7 +1396,7 @@ if ('onhashchange' in window) { 1335 local-scope 1336 x:text <- new [abc] 1337 run [ -1338 y:text <- copy-range x, 3, 3 +1338 y:text <- copy-range x, 3, 3 1339 1:@:char/raw <- copy *y 1340 ] 1341 memory-should-contain [ @@ -1404,7 +1404,7 @@ if ('onhashchange' in window) { 1343 ] 1344 ] 1345 -1346 def parse-whole-number in:text -> out:num, error?:bool [ +1346 def parse-whole-number in:text -> out:num, error?:bool [ 1347 local-scope 1348 load-inputs 1349 out <- copy 0 @@ -1416,7 +1416,7 @@ if ('onhashchange' in window) { 1355 break-if done? 1356 c:char <- index *in, i 1357 x:num <- character-to-code c -1358 digit:num, error?:bool <- character-code-to-digit x +1358 digit:num, error?:bool <- character-code-to-digit x 1359 return-if error? 1360 result <- multiply result, 10 1361 result <- add result, digit @@ -1428,7 +1428,7 @@ if ('onhashchange' in window) { 1367 ] 1368 1369 # (contributed by Ella Couch) -1370 recipe character-code-to-digit character-code:number -> result:number, error?:boolean [ +1370 recipe character-code-to-digit character-code:number -> result:number, error?:boolean [ 1371 local-scope 1372 load-inputs 1373 result <- copy 0 @@ -1443,7 +1443,7 @@ if ('onhashchange' in window) { 1382 local-scope 1383 a:number <- copy 48 # character code for '0' 1384 run [ -1385 10:number/raw, 11:boolean/raw <- character-code-to-digit a +1385 10:number/raw, 11:boolean/raw <- character-code-to-digit a 1386 ] 1387 memory-should-contain [ 1388 10 <- 0 @@ -1455,7 +1455,7 @@ if ('onhashchange' in window) { 1394 local-scope 1395 a:number <- copy 57 # character code for '9' 1396 run [ -1397 1:number/raw, 2:boolean/raw <- character-code-to-digit a +1397 1:number/raw, 2:boolean/raw <- character-code-to-digit a 1398 ] 1399 memory-should-contain [ 1400 1 <- 9 @@ -1467,7 +1467,7 @@ if ('onhashchange' in window) { 1406 local-scope 1407 a:number <- copy 47 1408 run [ -1409 10:number/raw, 11:boolean/raw <- character-code-to-digit a +1409 10:number/raw, 11:boolean/raw <- character-code-to-digit a 1410 ] 1411 memory-should-contain [ 1412 10 <- 0 @@ -1479,7 +1479,7 @@ if ('onhashchange' in window) { 1418 local-scope 1419 a:number <- copy 58 1420 run [ -1421 10:number/raw, 11:boolean/raw <- character-code-to-digit a +1421 10:number/raw, 11:boolean/raw <- character-code-to-digit a 1422 ] 1423 memory-should-contain [ 1424 10 <- 0 -- cgit 1.4.1-2-gfad0