From f705e1a18f7ca437095b8db32198042d8a637129 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 31 Jul 2022 10:25:27 -0500 Subject: [PATCH] sequences: bound -> index-or-length --- basis/farkup/farkup.factor | 2 +- basis/formatting/formatting.factor | 2 +- basis/furnace/syndication/syndication.factor | 2 +- basis/help/apropos/apropos.factor | 2 +- basis/help/syntax/syntax.factor | 2 +- basis/logging/analysis/analysis.factor | 2 +- basis/multiline/multiline.factor | 2 +- basis/prettyprint/prettyprint.factor | 2 +- basis/simple-flat-file/simple-flat-file.factor | 2 +- basis/tools/completion/completion.factor | 2 +- basis/tools/trace/trace.factor | 2 +- basis/ui/gadgets/incremental/incremental.factor | 2 +- basis/ui/tools/listener/completion/completion.factor | 2 +- basis/ui/tools/listener/listener.factor | 2 +- basis/uuid/uuid.factor | 4 ++-- core/sequences/sequences-docs.factor | 10 +++++----- core/sequences/sequences.factor | 2 +- core/strings/parser/parser.factor | 2 +- core/system/system.factor | 2 +- extra/codebase-analyzer/codebase-analyzer.factor | 8 ++++---- extra/colors/flex-hex/flex-hex.factor | 4 ++-- extra/hacker-news/hacker-news.factor | 2 +- extra/id3/id3.factor | 2 +- extra/mason/email/email.factor | 2 +- extra/mason/report/report.factor | 2 +- extra/pdf/layout/layout.factor | 4 ++-- extra/project-euler/117/117.factor | 2 +- extra/rosetta-code/top-rank/top-rank.factor | 2 +- extra/spider/report/report.factor | 2 +- extra/syslog/syslog.factor | 2 +- extra/ui/gadgets/charts/lines/lines.factor | 2 +- extra/webapps/planet/planet.factor | 2 +- extra/youtube/youtube.factor | 2 +- 33 files changed, 43 insertions(+), 43 deletions(-) diff --git a/basis/farkup/farkup.factor b/basis/farkup/farkup.factor index 92b2824fc1..1c901d9fdb 100644 --- a/basis/farkup/farkup.factor +++ b/basis/farkup/farkup.factor @@ -50,7 +50,7 @@ DEFER: (parse-paragraph) parse-paragraph paragraph boa ; : cut-half-slice ( string i -- before after-slice ) - [ head ] [ 1 + bound tail-slice ] 2bi ; + [ head ] [ 1 + index-or-length tail-slice ] 2bi ; : find-cut ( string quot -- before after delimiter ) dupd find diff --git a/basis/formatting/formatting.factor b/basis/formatting/formatting.factor index 5de21901b3..535133e7b6 100644 --- a/basis/formatting/formatting.factor +++ b/basis/formatting/formatting.factor @@ -106,7 +106,7 @@ pad = pad-align pad-char pad-width => [[ >quotation dup first 0 sign_ = [+ ] => [[ '[ dup first CHAR: - = [ _ prefix ] unless ] ]] sign = (sign_)? => [[ [ ] or ]] -width_ = "." ([0-9])* => [[ second >digits '[ _ bound head ] ]] +width_ = "." ([0-9])* => [[ second >digits '[ _ index-or-length head ] ]] width = (width_)? => [[ [ ] or ]] digits_ = "." ([0-9])* => [[ second >digits ]] diff --git a/basis/furnace/syndication/syndication.factor b/basis/furnace/syndication/syndication.factor index ad3a1b9127..3311b84a7c 100644 --- a/basis/furnace/syndication/syndication.factor +++ b/basis/furnace/syndication/syndication.factor @@ -29,7 +29,7 @@ M: object >entry } cleave ; : process-entries ( seq -- seq' ) - 20 bound head-slice [ + 20 index-or-length head-slice [ >entry clone [ adjust-url ] change-url ] map ; diff --git a/basis/help/apropos/apropos.factor b/basis/help/apropos/apropos.factor index 0dd9eb0d57..1becf02529 100644 --- a/basis/help/apropos/apropos.factor +++ b/basis/help/apropos/apropos.factor @@ -52,7 +52,7 @@ M: more-completions article-content completions [ [ { $heading search } , - [ max-completions bound head keys \ $completions prefix , ] + [ max-completions index-or-length head keys \ $completions prefix , ] [ length max-completions > [ { $link T{ more-completions f completions search category } } , ] when diff --git a/basis/help/syntax/syntax.factor b/basis/help/syntax/syntax.factor index ba658aa3fb..2cb4614c6c 100644 --- a/basis/help/syntax/syntax.factor +++ b/basis/help/syntax/syntax.factor @@ -91,7 +91,7 @@ DEFER: HELP{ : trim-whitespace ( seq -- seq' ) dup rest-slice dup whitespace - [ '[ _ bound tail ] map! ] unless-zero drop + [ '[ _ index-or-length tail ] map! ] unless-zero drop 0 over [ [ blank? ] trim-head ] change-nth ; : code-lines ( str -- seq ) diff --git a/basis/logging/analysis/analysis.factor b/basis/logging/analysis/analysis.factor index baeeeb0b16..84c2674009 100644 --- a/basis/logging/analysis/analysis.factor +++ b/basis/logging/analysis/analysis.factor @@ -20,7 +20,7 @@ SYMBOL: message-histogram drop ; : recent-histogram ( assoc n -- alist ) - [ sort-values ] dip bound head ; + [ sort-values ] dip index-or-length head ; : analyze-entries ( entries word-names -- errors word-histogram message-histogram ) [ diff --git a/basis/multiline/multiline.factor b/basis/multiline/multiline.factor index cd33adc9be..975d88493f 100644 --- a/basis/multiline/multiline.factor +++ b/basis/multiline/multiline.factor @@ -44,7 +44,7 @@ SYNTAX: STRING: i text end subseq-index-from [| j | i j text subseq % j end length + ] [ - text i bound tail % CHAR: \n , + text i index-or-length tail % CHAR: \n , lexer next-line 0 end lexer (scan-multiline-string) ] if* diff --git a/basis/prettyprint/prettyprint.factor b/basis/prettyprint/prettyprint.factor index f389b351ec..a96a1eec1d 100644 --- a/basis/prettyprint/prettyprint.factor +++ b/basis/prettyprint/prettyprint.factor @@ -70,7 +70,7 @@ SYMBOL: => ] [ ] make ; : remove-breakpoints ( quot pos -- quot' ) - 1 + bound cut [ (remove-breakpoints) ] bi@ [ => ] glue ; + 1 + index-or-length cut [ (remove-breakpoints) ] bi@ [ => ] glue ; : optimized-frame? ( triple -- ? ) second word? ; diff --git a/basis/simple-flat-file/simple-flat-file.factor b/basis/simple-flat-file/simple-flat-file.factor index e6c5233f89..d9d2bfb97e 100644 --- a/basis/simple-flat-file/simple-flat-file.factor +++ b/basis/simple-flat-file/simple-flat-file.factor @@ -12,7 +12,7 @@ IN: simple-flat-file [ drop-comment ] map harvest ; : split-column ( line -- columns ) - " \t" split harvest 2 bound head 2 f pad-tail ; + " \t" split harvest 2 index-or-length head 2 f pad-tail ; : parse-hex ( s -- n ) dup [ diff --git a/basis/tools/completion/completion.factor b/basis/tools/completion/completion.factor index 49ca364ab5..63483d17f4 100644 --- a/basis/tools/completion/completion.factor +++ b/basis/tools/completion/completion.factor @@ -146,7 +146,7 @@ PRIVATE> { ";" } split1-last [ ] [ ] ?if ; : complete-vocab-list? ( tokens -- ? ) - chop-; 1 bound head* "USING:" swap member? ; + chop-; 1 index-or-length head* "USING:" swap member? ; PRIVATE> diff --git a/basis/tools/trace/trace.factor b/basis/tools/trace/trace.factor index 622cfcb686..3f58dbc453 100644 --- a/basis/tools/trace/trace.factor +++ b/basis/tools/trace/trace.factor @@ -33,7 +33,7 @@ M: trace-step-state summary ] "" make ; : ( continuation word -- trace-step ) - [ nip ] [ [ data>> ] [ stack-effect in>> length ] bi* bound tail* ] 2bi + [ nip ] [ [ data>> ] [ stack-effect in>> length ] bi* index-or-length tail* ] 2bi \ trace-step-state boa ; : print-step ( continuation -- ) diff --git a/basis/ui/gadgets/incremental/incremental.factor b/basis/ui/gadgets/incremental/incremental.factor index 578594ad29..3b2d7c94b9 100644 --- a/basis/ui/gadgets/incremental/incremental.factor +++ b/basis/ui/gadgets/incremental/incremental.factor @@ -39,7 +39,7 @@ M: incremental dim-changed drop ; dup children>> length 200,000 > [ ! We let the length oscillate between 100k-200k, so we don't ! have to relayout the container every time a gadget is added. - [ 100,000 bound cut* ] change-children + [ 100,000 index-or-length cut* ] change-children ! Unfocus if any focused gadgets were removed and relayout dup focus>> pick member-eq? [ f >>focus ] when relayout yield diff --git a/basis/ui/tools/listener/completion/completion.factor b/basis/ui/tools/listener/completion/completion.factor index a67a076695..56cbc24f15 100644 --- a/basis/ui/tools/listener/completion/completion.factor +++ b/basis/ui/tools/listener/completion/completion.factor @@ -120,7 +120,7 @@ TUPLE: completion-popup < track interactor table completion-mode ; [ completion-popup? ] find-parent ; : ( editor element quot -- model ) - [ ] dip '[ @ >alist 100 bound head ] ; + [ ] dip '[ @ >alist 100 index-or-length head ] ; M: completion-popup focusable-child* table>> ; diff --git a/basis/ui/tools/listener/listener.factor b/basis/ui/tools/listener/listener.factor index e366aa543a..e87b06112b 100644 --- a/basis/ui/tools/listener/listener.factor +++ b/basis/ui/tools/listener/listener.factor @@ -162,7 +162,7 @@ M:: interactor stream-read-unsafe ( n buf interactor -- count ) n [ 0 ] [ drop interactor interactor-read dup [ join-lines ] when - n bound [ head-slice 0 buf copy ] keep + n index-or-length [ head-slice 0 buf copy ] keep ] if-zero ; M: interactor stream-read1 diff --git a/basis/uuid/uuid.factor b/basis/uuid/uuid.factor index 13b055a6c6..44e1fc9d15 100644 --- a/basis/uuid/uuid.factor +++ b/basis/uuid/uuid.factor @@ -64,7 +64,7 @@ PRIVATE> : uuid3 ( namespace name -- string ) [ uuid-parse ] dip append - md5 checksum-bytes 16 bound head be> + md5 checksum-bytes 16 index-or-length head be> 3 (version) uuid>string ; : uuid4 ( -- string ) @@ -73,7 +73,7 @@ PRIVATE> : uuid5 ( namespace name -- string ) [ uuid-parse ] dip append - sha1 checksum-bytes 16 bound head be> + sha1 checksum-bytes 16 index-or-length head be> 5 (version) uuid>string ; : uuid6 ( -- string ) diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 54e7d705b7..beee253aa3 100644 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -1080,7 +1080,7 @@ HELP: head } "When a sequence may not have enough elements:" { $example "USING: sequences prettyprint ;" - "{ 1 2 } 5 bound head ." + "{ 1 2 } 5 index-or-length head ." "{ 1 2 }" } } @@ -1096,7 +1096,7 @@ HELP: tail } "When a sequence may not have enough elements:" { $example "USING: sequences prettyprint ;" - "{ 1 2 } 5 bound tail ." + "{ 1 2 } 5 index-or-length tail ." "{ }" } } @@ -1122,7 +1122,7 @@ HELP: head* } "When a sequence may not have enough elements:" { $example "USING: sequences prettyprint ;" - "{ 1 2 } 5 bound head* ." + "{ 1 2 } 5 index-or-length head* ." "{ }" } } @@ -1138,7 +1138,7 @@ HELP: tail* } "When a sequence may not have enough elements:" { $example "USING: sequences prettyprint ;" - "{ 1 2 } 5 bound tail* ." + "{ 1 2 } 5 index-or-length tail* ." "{ 1 2 }" } } @@ -1632,7 +1632,7 @@ HELP: bound { "seq" sequence } { "n" integer } { "n'" integer } } { $description "Returns the input sequence and its length or " { $snippet "n" } ", whichever is less." } { $examples { $example "USING: sequences kernel prettyprint ;" - "\"abcd\" 3 bound [ . ] bi@" + "\"abcd\" 3 index-or-length [ . ] bi@" "\"abcd\"\n3" } } ; diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 213b2f95f0..7ff0947f28 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -247,7 +247,7 @@ M: slice virtual@ [ from>> + ] [ seq>> ] bi ; inline M: slice length [ to>> ] [ from>> ] bi - ; inline -: bound ( seq n -- seq n' ) over length min ; inline +: index-or-length ( seq n -- seq n' ) over length min ; inline : head-slice ( seq n -- slice ) head-to-index ; inline diff --git a/core/strings/parser/parser.factor b/core/strings/parser/parser.factor index 8cd30f37f4..bff33f2429 100644 --- a/core/strings/parser/parser.factor +++ b/core/strings/parser/parser.factor @@ -36,7 +36,7 @@ name>char-hook [ 2 cut-slice [ hex> ] dip ; : oct-escape ( str -- ch/f str' ) - dup 3 bound head-slice [ + dup 3 index-or-length head-slice [ [ CHAR: 0 CHAR: 7 between? not ] find drop ] keep '[ _ length ] unless* [ f ] when-zero [ cut-slice [ oct> ] dip ] [ f swap ] if* ; diff --git a/core/system/system.factor b/core/system/system.factor index 397f7466ca..03d01e2d1d 100644 --- a/core/system/system.factor +++ b/core/system/system.factor @@ -77,7 +77,7 @@ PRIVATE> " " % cpu name>> % " (" % build # ", " % vm-git-ref % "-" % - vm-git-id 10 bound head % ", " % + vm-git-id 10 index-or-length head % ", " % vm-compile-time % ")\n[" % vm-compiler % "] on " % os name>> % ] "" make ; diff --git a/extra/codebase-analyzer/codebase-analyzer.factor b/extra/codebase-analyzer/codebase-analyzer.factor index c0b4226265..ab5a80a429 100644 --- a/extra/codebase-analyzer/codebase-analyzer.factor +++ b/extra/codebase-analyzer/codebase-analyzer.factor @@ -167,10 +167,10 @@ IN: codebase-analyzer [ uses-make? [ "uses make" print ] when ] [ rc-files [ length "has %d rc files" sprintf print ] unless-empty ] [ ignore-files [ length "has %d ignore files" sprintf print ] unless-empty nl ] - [ "Top 20 largest files" print file-sizes sort-values 20 bound tail* [ normalize-path ] map-keys reverse assoc. nl ] - [ "Top 10 file extension sizes" print sum-sizes-by-extension 10 bound tail* reverse assoc. nl ] - [ "Top 10 text file line counts" print sum-line-counts-by-extension 10 bound tail* reverse assoc. nl ] - [ "Top 10 file extension counts" print count-by-file-extension 10 bound tail* reverse assoc. nl ] + [ "Top 20 largest files" print file-sizes sort-values 20 index-or-length tail* [ normalize-path ] map-keys reverse assoc. nl ] + [ "Top 10 file extension sizes" print sum-sizes-by-extension 10 index-or-length tail* reverse assoc. nl ] + [ "Top 10 text file line counts" print sum-line-counts-by-extension 10 index-or-length tail* reverse assoc. nl ] + [ "Top 10 file extension counts" print count-by-file-extension 10 index-or-length tail* reverse assoc. nl ] } cleave ; : analyze-codebase ( path -- ) diff --git a/extra/colors/flex-hex/flex-hex.factor b/extra/colors/flex-hex/flex-hex.factor index d75f3b2930..b964d6ed50 100644 --- a/extra/colors/flex-hex/flex-hex.factor +++ b/extra/colors/flex-hex/flex-hex.factor @@ -19,8 +19,8 @@ IN: colors.flex-hex : hex-rgb ( array -- array' ) [ - 8 bound tail* - 2 bound head + 8 index-or-length tail* + 2 index-or-length head 2 CHAR: 0 pad-head ] map ; diff --git a/extra/hacker-news/hacker-news.factor b/extra/hacker-news/hacker-news.factor index a4bc74ce04..212b7fd5b9 100644 --- a/extra/hacker-news/hacker-news.factor +++ b/extra/hacker-news/hacker-news.factor @@ -20,7 +20,7 @@ CONSTANT: christmas-green COLOR: #376627 "https://hacker-news.firebaseio.com/v0/item/%d.json?print=pretty" sprintf ; : hacker-news-items ( n endpoint -- seq ) - hacker-news-ids swap bound head + hacker-news-ids swap index-or-length head [ hacker-news-id>json-url http-get nip json> ] parallel-map ; : hacker-news-top-stories ( n -- seq ) diff --git a/extra/id3/id3.factor b/extra/id3/id3.factor index 2e81717d3c..17d79abf51 100644 --- a/extra/id3/id3.factor +++ b/extra/id3/id3.factor @@ -116,7 +116,7 @@ CONSTANT: id3v1+-length 227 [ 10 over size>> 10 + ] dip filter-text-data ; : decode-text ( string -- string' ) - dup 2 bound head + dup 2 index-or-length head { { 0xff 0xfe } { 0xfe 0xff } } member? utf16 ascii ? decode ; diff --git a/extra/mason/email/email.factor b/extra/mason/email/email.factor index ddeec95bc5..ebe869cc29 100644 --- a/extra/mason/email/email.factor +++ b/extra/mason/email/email.factor @@ -25,7 +25,7 @@ IN: mason.email : report-subject ( status -- string ) [ subject-prefix % - current-git-id get 7 bound head % + current-git-id get 7 index-or-length head % " -- " % { { status-clean [ "clean" ] } diff --git a/extra/mason/report/report.factor b/extra/mason/report/report.factor index 0ec1e4bf48..3dffe3d54b 100644 --- a/extra/mason/report/report.factor +++ b/extra/mason/report/report.factor @@ -37,7 +37,7 @@ IN: mason.report ] with-file-writer ; inline : file-tail ( file encoding lines -- seq ) - [ file-lines ] dip bound tail* join-lines ; + [ file-lines ] dip index-or-length tail* join-lines ; :: failed-report ( error file what -- status ) [ diff --git a/extra/pdf/layout/layout.factor b/extra/pdf/layout/layout.factor index d8b976fcef..3f3c4a2fe3 100644 --- a/extra/pdf/layout/layout.factor +++ b/extra/pdf/layout/layout.factor @@ -101,7 +101,7 @@ M: p pdf-render [ over ?line-break over [ font>> ] [ avail-width ] bi visual-wrap - over avail-lines bound cut + over avail-lines index-or-length cut [ draw-text ] [ "" concat-as ] bi* ] change-string dup string>> empty? [ drop f ] when ; @@ -134,7 +134,7 @@ M: text pdf-render [ { } ] [ over [ font>> ] [ width ] bi visual-wrap ] if-empty ] dip [ prefix ] when* - over avail-lines bound cut + over avail-lines index-or-length cut [ draw-text ] [ "" concat-as ] bi* ] change-string dup string>> empty? [ drop f ] when ; diff --git a/extra/project-euler/117/117.factor b/extra/project-euler/117/117.factor index 255fb20bea..ae23776f6b 100644 --- a/extra/project-euler/117/117.factor +++ b/extra/project-euler/117/117.factor @@ -28,7 +28,7 @@ IN: project-euler.117 > ] inv-sort-with ] assoc-map ; : first-n-each ( seq n quot -- ) - [ bound head-slice ] dip each ; inline + [ index-or-length head-slice ] dip each ; inline : top-rank-main ( -- ) employees prepare-departments [ diff --git a/extra/spider/report/report.factor b/extra/spider/report/report.factor index 99c7a720c0..711d8e4a6d 100644 --- a/extra/spider/report/report.factor +++ b/extra/spider/report/report.factor @@ -36,7 +36,7 @@ SYMBOL: time-std : process-timings ( -- ) timings get sort-values - [ slowest bound tail* reverse slowest-pages set ] + [ slowest index-or-length tail* reverse slowest-pages set ] [ values [ [ mean 1000000 /f mean-time set ] diff --git a/extra/syslog/syslog.factor b/extra/syslog/syslog.factor index 992b7b9cc8..998c873f22 100644 --- a/extra/syslog/syslog.factor +++ b/extra/syslog/syslog.factor @@ -65,7 +65,7 @@ PRIVATE> : syslog ( message level -- ) utf8 [ write-syslog ] with-byte-writer - 1024 bound head + 1024 index-or-length head syslog-server get-global $[ f 0 ] send ; diff --git a/extra/ui/gadgets/charts/lines/lines.factor b/extra/ui/gadgets/charts/lines/lines.factor index f56c9f9358..89d9fb58c4 100644 --- a/extra/ui/gadgets/charts/lines/lines.factor +++ b/extra/ui/gadgets/charts/lines/lines.factor @@ -38,7 +38,7 @@ ALIAS: y second ! right of the index, plus one that's not equal, if requested. :: adjusted-head-slice ( n elt plus-one? seq -- slice ) n seq elt x '[ x _ = not ] find-from drop seq swap - [ plus-one? [ 1 + ] when bound head-slice ] when* ; + [ plus-one? [ 1 + ] when index-or-length head-slice ] when* ; ! : data-rect ( data -- rect ) ! [ [ first x ] [ last x ] bi ] keep diff --git a/extra/webapps/planet/planet.factor b/extra/webapps/planet/planet.factor index 941caecee1..ff6d94a0a6 100644 --- a/extra/webapps/planet/planet.factor +++ b/extra/webapps/planet/planet.factor @@ -93,7 +93,7 @@ posting "POSTINGS" [ date>> ] inv-sort-with ; : update-cached-postings ( -- ) - blogroll fetch-blogroll sort-entries 8 bound head [ + blogroll fetch-blogroll sort-entries 8 index-or-length head [ posting new delete-tuples [ insert-tuple ] each ] with-transaction ; diff --git a/extra/youtube/youtube.factor b/extra/youtube/youtube.factor index 4d44b7a2fc..5c0e3b45d4 100644 --- a/extra/youtube/youtube.factor +++ b/extra/youtube/youtube.factor @@ -61,7 +61,7 @@ CONSTANT: video-info-url URL" http://www.youtube.com/get_video_info" : sanitize ( title -- title' ) [ 0 31 between? ] reject [ "\"#$%'*,./:;<>?^|~\\" member? ] reject - 200 bound head ; + 200 index-or-length head ; : downloadable? ( video-info -- ? ) "use_cipher_signature" of "False" = ; -- 2.34.1