USING: alien.libraries.finder sequences tools.test ;
-{ t } [ "m" find-library "libm.so" subseq-index? ] unit-test
-{ t } [ "c" find-library "libc.so" subseq-index? ] unit-test
+{ t } [ "m" find-library "libm.so" subseq-of? ] unit-test
+{ t } [ "c" find-library "libc.so" subseq-of? ] unit-test
[
" " split1 [ "()" in? ] trim "," split
[ [ unicode:blank? ] trim ] map
- [ ": Linux" subseq-index? ] reject
+ [ ": Linux" subseq-of? ] reject
] dip 3array
] map ;
"ld" , "-t" , ":" split [ "-L" , , ] each
"-o" , "/dev/null" , "-l" name append ,
] { } make utf8 [ read-lines ] with-process-reader* 2drop
- "lib" name append '[ _ subseq-index? ] find nip
+ "lib" name append '[ _ subseq-of? ] find nip
] [ f ] if* ;
PRIVATE>
} [ dyld-find ] map
] unit-test
-{ t } [ "m" find-library "libm.dylib" subseq-index? ] unit-test
-{ t } [ "c" find-library "libc.dylib" subseq-index? ] unit-test
-{ t } [ "bz2" find-library "libbz2.dylib" subseq-index? ] unit-test
-{ t } [ "AGL" find-library "AGL.framework" subseq-index? ] unit-test
+{ t } [ "m" find-library "libm.dylib" subseq-of? ] unit-test
+{ t } [ "c" find-library "libc.dylib" subseq-of? ] unit-test
+{ t } [ "bz2" find-library "libbz2.dylib" subseq-of? ] unit-test
+{ t } [ "AGL" find-library "AGL.framework" subseq-of? ] unit-test
USING: alien.libraries.finder sequences tools.test ;
-{ t } [ "kernel32" find-library "kernel32.dll" subseq-index? ] unit-test
+{ t } [ "kernel32" find-library "kernel32.dll" subseq-of? ] unit-test
: running.app? ( -- ? )
! Test if we're running a .app.
NSBundle -> mainBundle -> bundlePath CF>string
- ".app" subseq-index? ;
+ ".app" subseq-of? ;
: assert.app ( message -- )
running.app? [
"sql-spec" get modifiers>> [ +not-null+ = ] none? ;
: delete-cascade? ( -- ? )
- "sql-spec" get modifiers>> { +on-delete+ +cascade+ } subseq-index? ;
+ "sql-spec" get modifiers>> { +on-delete+ +cascade+ } subseq-of? ;
: sqlite-trigger, ( string -- )
{ } { } <simple-statement> 3, ;
ERROR: domain-name-contains-empty-label domain ;
: check-domain-name ( domain -- domain )
- dup ".." subseq-index? [ domain-name-contains-empty-label ] when ;
+ dup ".." subseq-of? [ domain-name-contains-empty-label ] when ;
: >dotted ( domain -- domain' )
dup "." tail? [ "." append ] unless ;
{ "(all-integers?)" { "all-integers-from?" "0.99" } }
{ "short" { "index-or-length" "0.99" } }
{ "map-integers" { "map-integers-as" "0.99" } }
- { "deep-subseq?" { "deep-subseq-index?" "0.99" } }
+ { "deep-subseq?" { "deep-subseq-of?" "0.99" } }
}
: compute-assoc-fixups ( continuation name assoc -- seq )
" white-space: pre-wrap; line-height: 125%;" append
] re-replace-with
- dup { "font-family: monospace;" "background-color:" } [ subseq-index? ] with all? [
+ dup { "font-family: monospace;" "background-color:" } [ subseq-of? ] with all? [
" margin: 10px 0px;" append
] when
- dup { "border:" "background-color:" } [ subseq-index? ] with all? [
+ dup { "border:" "background-color:" } [ subseq-of? ] with all? [
" border-radius: 5px;" append
] when ;
: fix-help-header ( classes -- classes )
dup [
- [ ".a" head? ] [ "#f4efd9;" subseq-index? ] bi and
+ [ ".a" head? ] [ "#f4efd9;" subseq-of? ] bi and
] find [
"padding: 10px;" "padding: 0px;" replace
"background-color: #f4efd9;" "background-color: white;" replace
] re-replace-with
] map " " join "{ " " }" surround
] re-replace-with " " prepend
- dup "{ }" subseq-index? [ drop f ] when
+ dup "{ }" subseq-of? [ drop f ] when
] map harvest append "}" suffix ;
: css-classes ( classes -- stylesheet )
] each classes sort-values css-classes body ;
: retina-image ( path -- path' )
- dup "@2x" subseq-index? [ "." split1-last "@2x." glue ] unless ;
+ dup "@2x" subseq-of? [ "." split1-last "@2x." glue ] unless ;
: ?copy-file ( from to -- )
dup file-exists? [ 2drop ] [ copy-file ] if ;
simple-lint-error
] when
] [
- " " subseq-index? [
+ " " subseq-of? [
"Paragraph text should not contain double spaces"
simple-lint-error
] when
first [
{ [ CHAR: space = ] [ CHAR: " = ] } 1||
] trim-head
- " " subseq-index?
+ " " subseq-of?
] filter
[ drop ] [
swap <pathname> .
search-words [ { } ] [
[ all-articles ] dip
dup length 1 > [
- '[ article-words _ subseq-index? ] filter
+ '[ article-words _ subseq-of? ] filter
] [
first '[ article-words [ _ head? ] any? ] filter
] if
! hit the velox.ch website.
! { t } [
! "https://alice.sni.velox.ch" http-get nip
- ! [ "Great!" subseq-index? ]
- ! [ "TLS SNI Test Site: alice.sni.velox.ch" subseq-index? ] bi and
+ ! [ "Great!" subseq-of? ]
+ ! [ "TLS SNI Test Site: alice.sni.velox.ch" subseq-of? ] bi and
! ] unit-test
{ t } [
: message ( -- str )
55 [ "hello" ] replicate concat ;
-{ f } [ message >quoted "=\r\n" subseq-index? ] unit-test
+{ f } [ message >quoted "=\r\n" subseq-of? ] unit-test
{ 1 } [ message >quoted split-lines length ] unit-test
-{ t } [ message >quoted-lines "=\r\n" subseq-index? ] unit-test
+{ t } [ message >quoted-lines "=\r\n" subseq-of? ] unit-test
{ 4 } [ message >quoted-lines split-lines length ] unit-test
{ "===o" } [ message >quoted-lines split-lines [ last ] "" map-as ] unit-test
[ { { 1 2 3 } 4 } { { { 1 2 3 } 4 } 2 } deep-member? ] unit-test
{ f }
-[ { 1 2 3 { 4 } } { 1 2 3 4 } deep-subseq-index? ] unit-test
+[ { 1 2 3 { 4 } } { 1 2 3 4 } deep-subseq-of? ] unit-test
{ t }
-[ { 1 2 3 4 } { 1 2 3 4 } deep-subseq-index? ] unit-test
+[ { 1 2 3 4 } { 1 2 3 4 } deep-subseq-of? ] unit-test
{ t }
-[ { { 1 2 3 4 } } { 1 2 3 4 } deep-subseq-index? ] unit-test
+[ { { 1 2 3 4 } } { 1 2 3 4 } deep-subseq-of? ] unit-test
{ 3 } [
{ 1 { 2 3 { 4 } } 5 { { 6 } 7 } } 0 [
_ swap dup branch? [ member? ] [ 2drop f ] if
] deep-find >boolean ;
-: deep-subseq-index? ( seq subseq -- ? )
+: deep-subseq-of? ( seq subseq -- ? )
'[
- _ over branch? [ subseq-index? ] [ 2drop f ] if
+ _ over branch? [ subseq-of? ] [ 2drop f ] if
] deep-find >boolean ;
: deep-map! ( ... obj quot: ( ... elt -- ... elt' ) -- ... obj )
! Just verifies that the presented output contains a callstack.
{ t } [
create-test-failure [ error. ] with-string-writer
- "OBJ-CURRENT-THREAD" subseq-index?
+ "OBJ-CURRENT-THREAD" subseq-of?
] unit-test
<PRIVATE
MEMO: cached-image-path ( path -- image )
- [ load-image ] [ "@2x" subseq-index? >>2x? ] bi ;
+ [ load-image ] [ "@2x" subseq-of? >>2x? ] bi ;
PRIVATE>
{ $values { "subseq" sequence } { "seq" sequence } { "?" boolean } }
{ $description "Tests if " { $snippet "seq" } " contains the elements of " { $snippet "subseq" } " as a contiguous subsequence." } ;
-HELP: subseq-index?
+HELP: subseq-of?
{ $values { "seq" sequence } { "subseq" sequence } { "?" boolean } }
{ $description "Tests if " { $snippet "seq" } " contains the elements of " { $snippet "subseq" } " as a contiguous subsequence." } ;
"Testing if a sequence contains an object:"
{ $subsections member? member-eq? }
"Testing if a sequence contains a subsequence:"
-{ $subsections head? tail? subseq? subseq-index? } ;
+{ $subsections head? tail? subseq? subseq-of? } ;
ARTICLE: "sequences-search" "Searching sequences"
"Finding the index of an element:"
: subseq-index ( seq subseq -- i/f ) [ 0 ] 2dip subseq-index-from ; inline
-: subseq-index? ( seq subseq -- ? ) subseq-index >boolean ; inline
+: subseq-of? ( seq subseq -- ? ) subseq-index >boolean ; inline
: subseq-start-from ( subseq seq n -- i/f )
spin subseq-index-from ; inline deprecated
{ f } [ CHAR: I "team" member? ] unit-test
{ t } [ "ea" "team" subseq? ] unit-test
{ f } [ "actore" "Factor" subseq? ] unit-test
-{ t } [ "team" "ea" subseq-index? ] unit-test
-{ f } [ "Factor" "actore" subseq-index? ] unit-test
+{ t } [ "team" "ea" subseq-of? ] unit-test
+{ f } [ "Factor" "actore" subseq-of? ] unit-test
{ "end" } [ "Beginning and end" 14 tail ] unit-test
{ { t t t } } [
version-info
vm-version vm-compiler vm-compile-time 3array
- [ subseq-index? ] with map
+ [ subseq-of? ] with map
] unit-test
dup "announce-list" of [ nip first random ] [ "announce" of ] if* ;
: scrape-url ( metainfo -- url/f )
- announce-url dup path>> "announce" subseq-index? [
+ announce-url dup path>> "announce" subseq-of? [
[ "announce" "scrape" replace ] change-path
] [ drop f ] if ;
: directory-entries-without-git ( directory -- entries )
recursive-directory-entries
- [ name>> "/.git/" subseq-index? ] reject ;
+ [ name>> "/.git/" subseq-of? ] reject ;
[ has-file-extension? ] filter ;
: without-git-paths ( paths -- paths' )
- [ "/.git/" subseq-index? ] reject ;
+ [ "/.git/" subseq-of? ] reject ;
: without-node-modules-paths ( paths -- paths' )
- [ "/node_modules/" subseq-index? ] reject ;
+ [ "/node_modules/" subseq-of? ] reject ;
: regular-directory-files ( path -- seq )
recursive-directory-files
: gemini-go ( args -- )
present [ DEFAULT-URL ] when-empty
- { [ dup "://" subseq-index? ] [ "gemini://" head? ] } 1||
+ { [ dup "://" subseq-of? ] [ "gemini://" head? ] } 1||
[ "gemini://" prepend ] unless
dup "gemini://" head? [
[ add-history ] [ add-stack ] [ gemini-get ] tri
[ url-field>> editor>> set-editor-string ] bi* ;
: ?gemini-url ( obj -- url )
- present dup "://" subseq-index? [ "gemini://" prepend ] unless >url ;
+ present dup "://" subseq-of? [ "gemini://" prepend ] unless >url ;
: show-gemini ( url gemini-gadget -- )
[ [ ?gemini-url ] [ f ] if* ] dip
[ url-field>> editor>> set-editor-string ] bi* ;
: ?gopher-url ( obj -- url )
- present dup "://" subseq-index? [ "gopher://" prepend ] unless >url ;
+ present dup "://" subseq-of? [ "gopher://" prepend ] unless >url ;
: show-gopher ( url gopher-gadget -- )
[ [ ?gopher-url ] [ f ] if* ] dip
[ { [ name>> = ] [ closing?>> not ] } 1&& ] with find-all ;
: href-contains? ( str tag -- ? )
- "href" attribute* [ swap subseq-index? ] [ 2drop f ] if ;
+ "href" attribute* [ swap subseq-of? ] [ 2drop f ] if ;
: find-hrefs ( vector -- vector' )
[ { [ name>> "a" = ] [ "href" attribute? ] } 1&& ] filter sift
M: object lint ( obj -- seq ) drop f ;
M: callable lint ( quot -- seq )
- lint-definitions-keys get-global [ subseq-index? ] with filter ;
+ lint-definitions-keys get-global [ subseq-of? ] with filter ;
M: word lint ( word -- seq/f )
def>> [ callable? ] deep-filter [ lint ] map concat ;
: git-pull-failed ( error -- )
dup output-process-error? [
- dup output>> "not uptodate. Cannot merge." subseq-index?
+ dup output>> "not uptodate. Cannot merge." subseq-of?
[ git-repo-corrupted ]
[ rethrow ]
if
] if ;
: parse-weather ( str -- str' )
- dup "VC" subseq-index? [ "VC" "" replace t ] [ f ] if
+ dup "VC" subseq-of? [ "VC" "" replace t ] [ f ] if
[ (parse-weather) ]
[ [ " in the vicinity" append ] when ] bi* ;
: <maxlicense> ( -- max ) -1 0 V{ } clone \ maxlicense boa ; inline
-: out? ( line -- ? ) "OUT" subseq-index? ; inline
+: out? ( line -- ? ) "OUT" subseq-of? ; inline
: line-time ( line -- time ) split-words harvest fourth ; inline
: name=value ( string -- remain term )
[ unicode:blank? ] trim
- dup ":`" subseq-index? [ (name=value) ] [ f swap ] if ;
+ dup ":`" subseq-of? [ (name=value) ] [ f swap ] if ;
: name/values ( string -- remain terms )
[ dup { [ empty? not ] [ first CHAR: ` = not ] } 1&& ]
: zoneinfo-zones ( -- seq )
raw-zone-map keys
- [ "/" subseq-index? ] partition
+ [ "/" subseq-of? ] partition
[ natural-sort ] bi@ append ;
GENERIC: zone-matches? ( string rule -- ? )
: comparison-day-string ( timestamp string -- timestamp )
{
- { [ dup ">=" subseq-index? ] [ ">=" split1 swap [ string>number >>day ] dip day-abbrev>= ] }
- { [ dup "<=" subseq-index? ] [ "<=" split1 swap [ string>number >>day ] dip day-abbrev<= ] }
+ { [ dup ">=" subseq-of? ] [ ">=" split1 swap [ string>number >>day ] dip day-abbrev>= ] }
+ { [ dup "<=" subseq-of? ] [ "<=" split1 swap [ string>number >>day ] dip day-abbrev<= ] }
[ string>number >>day ]
} cond ;
SynKeywordFactorWord factorWord_math_order | syn keyword factorWord_math_order contained +eq+ +gt+ +lt+ <=> >=< [-] after=? after? before=? before? between? clamp compare invert-comparison max min
SynKeywordFactorWord factorWord_memory | syn keyword factorWord_memory contained all-instances compact-gc gc instances minor-gc save save-image save-image-and-exit saving-path size
SynKeywordFactorWord factorWord_namespaces | syn keyword factorWord_namespaces contained +@ change change-global counter dec get get-global get-namestack global inc init-namestack initialize namespace off on set set-global set-namestack toggle with-global with-scope with-variable with-variables
-SynKeywordFactorWord factorWord_sequences | syn keyword factorWord_sequences contained 1sequence 1surround 1surround-as 2all? 2any? 2each 2each-from 2map 2map-as 2map-reduce 2reduce 2selector 2sequence 3append 3append-as 3each 3map 3map-as 3sequence 4sequence <iota> <repetition> <reversed> <slice> >slice< ?first ?last ?nth ?second ?set-nth accumulate accumulate! accumulate* accumulate*! accumulate*-as accumulate-as all? any? append append! append-as assert-sequence assert-sequence= assert-sequence? binary-reduce bounds-check bounds-check? bounds-error bounds-error? but-last but-last-slice cartesian-each cartesian-find cartesian-map cartesian-product cartesian-product-as change-nth check-slice clone-like collapse-slice collector collector-as collector-for collector-for-as concat concat-as copy count cut cut* cut-slice cut-slice* delete-all delete-slice drop-prefix each each-from each-index empty? exchange filter filter! filter-as find find-from find-index find-index-from find-last find-last-from first first2 first3 first4 flip follow fourth from-tail glue glue-as halves harvest head head* head-slice head-slice* head-to-index head? if-empty immutable immutable-sequence immutable-sequence? immutable? index index-from index-of-last index-or-length index-to-tail indices infimum infimum-by insert-nth interleave iota iota? join join-as last last-index last-index-from length lengthen like longer longer? longest map map! map-as map-find map-find-last map-index map-index-as map-integers map-integers-as map-reduce map-sum max-length member-eq? member? midpoint@ min-length mismatch move new-like new-resizable new-sequence non-negative-integer-expected non-negative-integer-expected? none? nth nths pad-head pad-tail partition pop pop* prefix prepend prepend-as produce produce-as product push push-all push-either push-if reduce reduce-index reject reject! reject-as remove remove! remove-eq remove-eq! remove-nth remove-nth! repetition repetition? replace-slice replicate replicate-as rest rest-slice reverse reverse! reversed reversed? second selector selector-as sequence sequence-hashcode sequence= sequence? set-first set-fourth set-last set-length set-nth set-second set-third shorten shorter shorter? shortest sift slice slice-error slice-error? slice? snip snip-slice subseq subseq-as subseq-index subseq-index-from subseq-index? subseq-start subseq-start-from subseq-starts-at? subseq? suffix suffix! sum sum-lengths supremum supremum-by surround surround-as tail tail* tail-slice tail-slice* tail? third trim trim-head trim-head-slice trim-slice trim-tail trim-tail-slice unclip unclip-last unclip-last-slice unclip-slice unless-empty virtual-exemplar virtual-sequence virtual-sequence? virtual@ when-empty
+SynKeywordFactorWord factorWord_sequences | syn keyword factorWord_sequences contained 1sequence 1surround 1surround-as 2all? 2any? 2each 2each-from 2map 2map-as 2map-reduce 2reduce 2selector 2sequence 3append 3append-as 3each 3map 3map-as 3sequence 4sequence <iota> <repetition> <reversed> <slice> >slice< ?first ?last ?nth ?second ?set-nth accumulate accumulate! accumulate* accumulate*! accumulate*-as accumulate-as all? any? append append! append-as assert-sequence assert-sequence= assert-sequence? binary-reduce bounds-check bounds-check? bounds-error bounds-error? but-last but-last-slice cartesian-each cartesian-find cartesian-map cartesian-product cartesian-product-as change-nth check-slice clone-like collapse-slice collector collector-as collector-for collector-for-as concat concat-as copy count cut cut* cut-slice cut-slice* delete-all delete-slice drop-prefix each each-from each-index empty? exchange filter filter! filter-as find find-from find-index find-index-from find-last find-last-from first first2 first3 first4 flip follow fourth from-tail glue glue-as halves harvest head head* head-slice head-slice* head-to-index head? if-empty immutable immutable-sequence immutable-sequence? immutable? index index-from index-of-last index-or-length index-to-tail indices infimum infimum-by insert-nth interleave iota iota? join join-as last last-index last-index-from length lengthen like longer longer? longest map map! map-as map-find map-find-last map-index map-index-as map-integers map-integers-as map-reduce map-sum max-length member-eq? member? midpoint@ min-length mismatch move new-like new-resizable new-sequence non-negative-integer-expected non-negative-integer-expected? none? nth nths pad-head pad-tail partition pop pop* prefix prepend prepend-as produce produce-as product push push-all push-either push-if reduce reduce-index reject reject! reject-as remove remove! remove-eq remove-eq! remove-nth remove-nth! repetition repetition? replace-slice replicate replicate-as rest rest-slice reverse reverse! reversed reversed? second selector selector-as sequence sequence-hashcode sequence= sequence? set-first set-fourth set-last set-length set-nth set-second set-third shorten shorter shorter? shortest sift slice slice-error slice-error? slice? snip snip-slice subseq subseq-as subseq-index subseq-index-from subseq-of? subseq-start subseq-start-from subseq-starts-at? subseq? suffix suffix! sum sum-lengths supremum supremum-by surround surround-as tail tail* tail-slice tail-slice* tail? third trim trim-head trim-head-slice trim-slice trim-tail trim-tail-slice unclip unclip-last unclip-last-slice unclip-slice unless-empty virtual-exemplar virtual-sequence virtual-sequence? virtual@ when-empty
SynKeywordFactorWord factorWord_sets | syn keyword factorWord_sets contained ?adjoin ?delete adjoin adjoin-all adjoin-at all-unique? cardinality clear-set delete diff diff! duplicates fast-set gather in? intersect intersect! intersect-all intersects? members null? set set-like set= set? subset? union union! union-all within without
SynKeywordFactorWord factorWord_sorting | syn keyword factorWord_sorting contained compare-with inv-sort-with natural-sort sort sort-keys sort-pair sort-values sort-with
SynKeywordFactorWord factorWord_splitting | syn keyword factorWord_splitting contained ?head ?head-slice ?snip ?snip-slice ?tail ?tail-slice join-lines join-lines-as join-words join-words-as replace split split-indices split-lines split-slice split-subseq split-when split-when-slice split-words split1 split1-last split1-last-slice split1-slice split1-when split1-when-slice string-lines subseq-range