USING: alien.libraries.finder sequences tools.test ;
-{ t } [ "m" find-library "libm.so" find-subseq? ] unit-test
-{ t } [ "c" find-library "libc.so" find-subseq? ] unit-test
+{ t } [ "m" find-library "libm.so" subsequence? ] unit-test
+{ t } [ "c" find-library "libc.so" subsequence? ] unit-test
[
" " split1 [ "()" in? ] trim "," split
[ [ unicode:blank? ] trim ] map
- [ ": Linux" find-subseq? ] reject
+ [ ": Linux" subsequence? ] 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 '[ _ find-subseq? ] find nip
+ "lib" name append '[ _ subsequence? ] find nip
] [ f ] if* ;
PRIVATE>
} [ dyld-find ] map
] unit-test
-{ t } [ "m" find-library "libm.dylib" find-subseq? ] unit-test
-{ t } [ "c" find-library "libc.dylib" find-subseq? ] unit-test
-{ t } [ "bz2" find-library "libbz2.dylib" find-subseq? ] unit-test
-{ t } [ "AGL" find-library "AGL.framework" find-subseq? ] unit-test
+{ t } [ "m" find-library "libm.dylib" subsequence? ] unit-test
+{ t } [ "c" find-library "libc.dylib" subsequence? ] unit-test
+{ t } [ "bz2" find-library "libbz2.dylib" subsequence? ] unit-test
+{ t } [ "AGL" find-library "AGL.framework" subsequence? ] unit-test
: framework-find ( name -- path )
dup dyld-find [ nip ] [
- dup ".framework" find-subseq [
+ dup ".framework" subsequence-starts [
dupd head
] [
[ ".framework" append ] keep
USING: alien.libraries.finder sequences tools.test ;
-{ t } [ "kernel32" find-library "kernel32.dll" find-subseq? ] unit-test
+{ t } [ "kernel32" find-library "kernel32.dll" subsequence? ] unit-test
"." write flush
{
- member-eq? split harvest sift cut cut-slice subseq-start find-subseq
+ member-eq? split harvest sift cut cut-slice subseq-start subsequence-starts
index clone set-at reverse push-all class-of number>string string>number
like clone-like
} compile-unoptimized
"sql-spec" get modifiers>> [ +not-null+ = ] none? ;
: delete-cascade? ( -- ? )
- "sql-spec" get modifiers>> { +on-delete+ +cascade+ } find-subseq? ;
+ "sql-spec" get modifiers>> { +on-delete+ +cascade+ } subsequence? ;
: sqlite-trigger, ( string -- )
{ } { } <simple-statement> 3, ;
ERROR: domain-name-contains-empty-label domain ;
: check-domain-name ( domain -- domain )
- dup ".." find-subseq? [ domain-name-contains-empty-label ] when ;
+ dup ".." subsequence? [ domain-name-contains-empty-label ] when ;
: >dotted ( domain -- domain' )
dup "." tail? [ "." append ] unless ;
" white-space: pre-wrap; line-height: 125%;" append
] re-replace-with
- { "font-family: monospace;" "background-color:" } [ find-subseq? ] with all?[
+ { "font-family: monospace;" "background-color:" } [ subsequence? ] with all?[
" margin: 10px 0px;" append
] when
- dup { "border:" "background-color:" } [ find-subseq? ] with all? [
+ dup { "border:" "background-color:" } [ subsequence? ] with all? [
" border-radius: 5px;" append
] when ;
: fix-help-header ( classes -- classes )
dup [
- [ ".a" head? ] [ "#f4efd9;" find-subseq? ] bi and
+ [ ".a" head? ] [ "#f4efd9;" subsequence? ] 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 "{ }" find-subseq? [ drop f ] when
+ dup "{ }" subsequence? [ drop f ] when
] map harvest append "}" suffix ;
: css-classes ( classes -- stylesheet )
] each classes sort-values css-classes body ;
: retina-image ( path -- path' )
- dup "@2x" find-subseq? [ "." split1-last "@2x." glue ] unless ;
+ dup "@2x" subsequence? [ "." split1-last "@2x." glue ] unless ;
: ?copy-file ( from to -- )
dup file-exists? [ 2drop ] [ copy-file ] if ;
simple-lint-error
] when
] [
- " " find-subseq? [
+ " " subsequence? [
"Paragraph text should not contain double spaces"
simple-lint-error
] when
first [
{ [ CHAR: space = ] [ CHAR: " = ] } 1||
] trim-head
- " " find-subseq?
+ " " subsequence?
] filter
[ drop ] [
swap <pathname> .
search-words [ { } ] [
[ all-articles ] dip
dup length 1 > [
- '[ article-words _ find-subseq? ] filter
+ '[ article-words _ subsequence? ] filter
] [
first '[ article-words [ _ head? ] any? ] filter
] if
DEFER: <% delimiter
: check-<% ( lexer -- col )
- [ column>> ] [ line-text>> ] bi "<%" find-subseq-from ;
+ [ column>> ] [ line-text>> ] bi "<%" subsequence-starts-from ;
: found-<% ( accum lexer col -- accum )
[
! hit the velox.ch website.
! { t } [
! "https://alice.sni.velox.ch" http-get nip
- ! [ "Great!" find-subseq? ]
- ! [ "TLS SNI Test Site: alice.sni.velox.ch" find-subseq? ] bi and
+ ! [ "Great!" subsequence? ]
+ ! [ "TLS SNI Test Site: alice.sni.velox.ch" subsequence? ] bi and
! ] unit-test
{ t } [
'[ _ curry filter ] <smart-arrow> ; inline
: <string-search> ( values search quot -- model )
- '[ swap @ [ >case-fold ] bi@ subseq? ] <search> ; inline
+ '[ @ [ >case-fold ] bi@ subsequence? ] <search> ; inline
:: (scan-multiline-string) ( i end lexer -- j )
lexer line-text>> :> text
lexer still-parsing? [
- i text end find-subseq-from [| j |
+ i text end subsequence-starts-from [| j |
i j text subseq % j end length +
] [
text i bound tail % CHAR: \n ,
: message ( -- str )
55 [ "hello" ] replicate concat ;
-{ f } [ message >quoted "=\r\n" find-subseq? ] unit-test
+{ f } [ message >quoted "=\r\n" subsequence? ] unit-test
{ 1 } [ message >quoted split-lines length ] unit-test
-{ t } [ message >quoted-lines "=\r\n" find-subseq? ] unit-test
+{ t } [ message >quoted-lines "=\r\n" subsequence? ] unit-test
{ 4 } [ message >quoted-lines split-lines length ] unit-test
{ "===o" } [ message >quoted-lines split-lines [ last ] "" map-as ] unit-test
: deep-subseq? ( subseq seq -- ? )
swap '[
- _ swap dup branch? [ subseq? ] [ 2drop f ] if
+ _ over branch? [ subsequence? ] [ 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" find-subseq?
+ "OBJ-CURRENT-THREAD" subsequence?
] unit-test
<PRIVATE
MEMO: cached-image-path ( path -- image )
- [ load-image ] [ "@2x" find-subseq? >>2x? ] bi ;
+ [ load-image ] [ "@2x" subsequence? >>2x? ] bi ;
PRIVATE>
{ $values { "i" "a start index" } { "seq" sequence } { "subseq" sequence } { "?" boolean } }
{ $description "Outputs " { $snippet "t" } " if the subseq starts at the " { $snippet "i" } "th element or outputs " { $link f } " if the sequence is not at that position." } ;
-HELP: find-subseq
+HELP: subsequence-starts
{ $values { "seq" sequence } { "subseq" sequence } { "i/f" "a start index or " { $snippet "f" } } }
{ $description "Outputs the start index of the first contiguous subsequence equal to " { $snippet "subseq" } ", starting the search from the " { $snippet "n" } "th element. If no matching subsequence is found, outputs " { $link f } "." } ;
-HELP: find-subseq-from
+HELP: subsequence-starts-from
{ $values { "n" "a start index" } { "seq" sequence } { "subseq" sequence } { "i/f" "a start index or " { $snippet "f" } } }
{ $description "Outputs the start index of the first contiguous subsequence equal to " { $snippet "subseq" } ", starting the search from the " { $snippet "n" } "th element. If no matching subsequence is found, outputs " { $link f } "." } ;
"Finding the start of a subsequence:"
{ $subsections
subseq-start
- find-subseq
- find-subseq-from
+ subsequence-starts
+ subsequence-starts-from
subseq-starts-at?
}
"Finding the index of an element satisfying a predicate:"
[ + _ nth-unsafe ] keep _ nth-unsafe =
] with all-integers? ; inline
-: find-subseq-from ( n seq subseq -- i/f )
+: subsequence-starts-from ( n seq subseq -- i/f )
[ [ length ] bi@ - 1 + ] 2keep
'[ _ _ subseq-starts-at? ] find-integer-from ; inline
-: subseq-start-from ( subseq seq n -- i/f ) spin find-subseq-from ; inline
+: subsequence-starts ( seq subseq -- i/f ) [ 0 ] 2dip subsequence-starts-from ; inline
-: find-subseq ( seq subseq -- i/f ) [ 0 ] 2dip find-subseq-from ; inline
+: subsequence? ( seq subseq -- ? ) subsequence-starts >boolean ; inline
-: find-subseq? ( seq subseq -- ? ) find-subseq >boolean ; inline
-
-: subseq-start ( subseq seq -- i/f ) swap find-subseq ; inline
+: subseq-start ( subseq seq -- i/f ) swap subsequence-starts ; inline
: subseq? ( subseq seq -- ? ) subseq-start >boolean ; inline
<PRIVATE
: subseq-range ( seq subseq -- from/f to/f )
- [ find-subseq ] keep '[ dup _ length + ] [ f f ] if* ; inline
+ [ subsequence-starts ] keep '[ dup _ length + ] [ f f ] if* ; inline
: (split1) ( seq subseq snip-quot -- before after )
[ [ subseq-range ] keepd over ] dip [ 2nip f ] if ; inline
{ f } [ CHAR: I "team" member? ] unit-test
{ t } [ "ea" "team" subseq? ] unit-test
{ f } [ "actore" "Factor" subseq? ] unit-test
-{ t } [ "team" "ea" find-subseq? ] unit-test
-{ f } [ "Factor" "actore" find-subseq? ] unit-test
+{ t } [ "team" "ea" subsequence? ] unit-test
+{ f } [ "Factor" "actore" subsequence? ] unit-test
{ "end" } [ "Beginning and end" 14 tail ] unit-test
{ { t t t } } [
version-info
vm-version vm-compiler vm-compile-time 3array
- [ find-subseq? ] with map
+ [ subsequence? ] with map
] unit-test
dup "announce-list" of [ nip first random ] [ "announce" of ] if* ;
: scrape-url ( metainfo -- url/f )
- announce-url dup path>> "announce" find-subseq? [
+ announce-url dup path>> "announce" subsequence? [
[ "announce" "scrape" replace ] change-path
] [ drop f ] if ;
: directory-entries-without-git ( directory -- entries )
recursive-directory-entries
- [ name>> "/.git/" find-subseq? ] reject ;
\ No newline at end of file
+ [ name>> "/.git/" subsequence? ] reject ;
\ No newline at end of file
[ has-file-extension? ] filter ;
: without-git-paths ( paths -- paths' )
- [ "/.git/" find-subseq? ] reject ;
+ [ "/.git/" subsequence? ] reject ;
: without-node-modules-paths ( paths -- paths' )
- [ "/node_modules/" find-subseq? ] reject ;
+ [ "/node_modules/" subsequence? ] reject ;
: regular-directory-files ( path -- seq )
recursive-directory-files
: gemini-go ( args -- )
present [ DEFAULT-URL ] when-empty
- { [ dup "://" find-subseq? ] [ "gemini://" head? ] } 1||
+ { [ dup "://" subsequence? ] [ "gemini://" head? ] } 1||
[ "gemini://" prepend ] unless
dup "gemini://" head? [
[ add-history ] [ add-stack ] [ gemini-get ] tri
[ { [ name>> = ] [ closing?>> not ] } 1&& ] with find-all ;
: href-contains? ( str tag -- ? )
- "href" attribute* [ swap find-subseq? ] [ 2drop f ] if ;
+ "href" attribute* [ swap subsequence? ] [ 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 [ find-subseq? ] with filter ;
+ lint-definitions-keys get-global [ subsequence? ] 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." find-subseq?
+ dup output>> "not uptodate. Cannot merge." subsequence?
[ git-repo-corrupted ]
[ rethrow ]
if
: nonce-already-used? ( assoc -- ? )
"error" of
[ "code" of "mwoauth-invalid-authorization" = ]
- [ "info" of "Nonce already used" find-subseq ] bi
+ [ "info" of "Nonce already used" subsequence-starts ] bi
and ;
: readonly? ( assoc -- ? )
] if ;
: parse-weather ( str -- str' )
- dup "VC" find-subseq? [ "VC" "" replace t ] [ f ] if
+ dup "VC" subsequence? [ "VC" "" replace t ] [ f ] if
[ (parse-weather) ]
[ [ " in the vicinity" append ] when ] bi* ;
ERROR: subseq-expected-but-got-eof n string expected ;
:: slice-til-string ( n string search -- n' string payload end-string )
- n string search find-subseq-from :> n'
+ n string search subsequence-starts-from :> n'
n' [ n string search subseq-expected-but-got-eof ] unless
n' search length + string
n n' string ?<slice>
: <maxlicense> ( -- max ) -1 0 V{ } clone \ maxlicense boa ; inline
-: out? ( line -- ? ) "OUT" find-subseq? ; inline
+: out? ( line -- ? ) "OUT" subsequence? ; inline
: line-time ( line -- time ) split-words harvest fourth ; inline
: web-scraping-main ( -- )
"http://tycho.usno.navy.mil/cgi-bin/timer.pl" http-get nip
- [ "UTC" find-subseq [ 9 - ] [ 1 - ] bi ] keep subseq print ;
+ [ "UTC" subsequence-starts [ 9 - ] [ 1 - ] bi ] keep subseq print ;
MAIN: web-scraping-main
: name=value ( string -- remain term )
[ unicode:blank? ] trim
- dup ":`" find-subseq? [ (name=value) ] [ f swap ] if ;
+ dup ":`" subsequence? [ (name=value) ] [ f swap ] if ;
: name/values ( string -- remain terms )
[ dup { [ empty? not ] [ first CHAR: ` = not ] } 1&& ]
: zoneinfo-zones ( -- seq )
raw-zone-map keys
- [ "/" find-subseq? ] partition
+ [ "/" subsequence? ] partition
[ natural-sort ] bi@ append ;
GENERIC: zone-matches? ( string rule -- ? )
: comparison-day-string ( timestamp string -- timestamp )
{
- { [ dup ">=" find-subseq? ] [ ">=" split1 swap [ string>number >>day ] dip day-abbrev>= ] }
- { [ dup "<=" find-subseq? ] [ "<=" split1 swap [ string>number >>day ] dip day-abbrev<= ] }
+ { [ dup ">=" subsequence? ] [ ">=" split1 swap [ string>number >>day ] dip day-abbrev>= ] }
+ { [ dup "<=" subsequence? ] [ "<=" split1 swap [ string>number >>day ] dip day-abbrev<= ] }
[ string>number >>day ]
} cond ;