Revert "sequences: swap stack arguments for start/start*/subseq?."

This reverts commit 63b0593824.
char-rename
John Benediktsson 2017-01-21 07:20:14 -08:00
parent 9dbd70ddd3
commit baaa06278c
33 changed files with 70 additions and 71 deletions

View File

@ -1,5 +1,5 @@
USING: alien.libraries.finder sequences tools.test ;
IN: alien.libraries.fidner.linux
{ t } [ "m" find-library "libm.so" subseq? ] unit-test
{ t } [ "c" find-library "libc.so" subseq? ] unit-test
{ t } [ "libm.so" "m" find-library subseq? ] unit-test
{ t } [ "libc.so" "c" find-library subseq? ] unit-test

View File

@ -44,7 +44,7 @@ IN: alien.libraries.finder.macosx
} [ dyld-find ] map
] unit-test
{ t } [ "m" find-library "libm.dylib" subseq? ] unit-test
{ t } [ "c" find-library "libc.dylib" subseq? ] unit-test
{ t } [ "bz2" find-library "libbz2.dylib" subseq? ] unit-test
{ t } [ "AGL" find-library "AGL.framework" subseq? ] unit-test
{ t } [ "libm.dylib" "m" find-library subseq? ] unit-test
{ t } [ "libc.dylib" "c" find-library subseq? ] unit-test
{ t } [ "libbz2.dylib" "bz2" find-library subseq? ] unit-test
{ t } [ "AGL.framework" "AGL" find-library subseq? ] unit-test

View File

@ -121,7 +121,7 @@ PRIVATE>
: framework-find ( name -- path )
dup dyld-find [ nip ] [
dup ".framework" start [
".framework" over start [
dupd head
] [
[ ".framework" append ] keep

View File

@ -40,8 +40,9 @@ FUNCTION: void NSBeep ( )
: running.app? ( -- ? )
! Test if we're running a .app.
".app"
NSBundle -> mainBundle -> bundlePath CF>string
".app" subseq? ;
subseq? ;
: assert.app ( message -- )
running.app? [

View File

@ -259,7 +259,7 @@ M: sqlite-db-connection persistent-table ( -- assoc )
"sql-spec" get modifiers>> [ +not-null+ = ] any? not ;
: delete-cascade? ( -- ? )
"sql-spec" get modifiers>> { +on-delete+ +cascade+ } subseq? ;
"sql-spec" get modifiers>> { +on-delete+ +cascade+ } swap subseq? ;
: sqlite-trigger, ( string -- )
{ } { } <simple-statement> 3, ;

View File

@ -338,7 +338,7 @@ M: iokit-game-input-backend get-controllers ( -- sequence )
+controller-states+ get-global keys [ controller boa ] map ;
: ?join ( pre post sep -- string )
2over swap start [ swap 2nip ] [ [ 2array ] dip join ] if ;
2over start [ swap 2nip ] [ [ 2array ] dip join ] if ;
M: iokit-game-input-backend product-string ( controller -- string )
handle>>

View File

@ -137,7 +137,7 @@ SYMBOL: vocab-articles
simple-lint-error
] when
] [
" " subseq? [
" " swap subseq? [
"Paragraph text should not contain double spaces"
simple-lint-error
] when

View File

@ -38,7 +38,7 @@ MEMO: article-words ( name -- words )
search-words [ { } ] [
[ all-articles ] dip
dup length 1 > [
'[ article-words _ subseq? ] filter
'[ article-words _ swap subseq? ] filter
] [
first '[ article-words [ _ head? ] any? ] filter
] if

View File

@ -25,7 +25,7 @@ M: template-lexer skip-word
DEFER: <% delimiter
: check-<% ( lexer -- col )
[ line-text>> "<%" ] [ column>> ] bi start ;
"<%" swap [ line-text>> ] [ column>> ] bi start* ;
: found-<% ( accum lexer col -- accum )
[

View File

@ -50,8 +50,8 @@ IN: http.client.tests
! hit the velox.ch website.
! { t } [
! "https://alice.sni.velox.ch" http-get nip
! [ "Great!" subseq? ]
! [ "TLS SNI Test Site: alice.sni.velox.ch" subseq? ] bi and
! [ "Great!" swap subseq? ]
! [ "TLS SNI Test Site: alice.sni.velox.ch" swap subseq? ] bi and
! ] unit-test
{ t } [

View File

@ -45,7 +45,8 @@ C: <mime-variable> mime-variable
: dump-until-separator ( multipart -- multipart )
dup
[ bytes>> ] [ current-separator>> ] bi dupd start [
[ current-separator>> ] [ bytes>> ] bi
[ nip ] [ start ] 2bi [
cut-slice
[ mime-write ]
[ over current-separator>> length short tail-slice >>bytes ] bi*

View File

@ -7,4 +7,4 @@ IN: models.search
'[ _ curry filter ] <smart-arrow> ; inline
: <string-search> ( values search quot -- model )
'[ swap @ [ >case-fold ] bi@ swap subseq? ] <search> ; inline
'[ swap @ [ >case-fold ] bi@ subseq? ] <search> ; inline

View File

@ -42,7 +42,7 @@ SYNTAX: STRING:
:: (scan-multiline-string) ( i end lexer -- j )
lexer line-text>> :> text
lexer still-parsing? [
text end i start* [| j |
end text i start* [| j |
i j text subseq % j end length +
] [
text i short tail % CHAR: \n ,

View File

@ -23,8 +23,8 @@ and we didn't know hów tö do thât" latin2 encode >quoted ] unit-test
: message ( -- str )
55 [ "hello" ] replicate concat ;
{ f } [ message >quoted "=\r\n" subseq? ] unit-test
{ f } [ message >quoted "=\r\n" swap subseq? ] unit-test
{ 1 } [ message >quoted string-lines length ] unit-test
{ t } [ message >quoted-lines "=\r\n" subseq? ] unit-test
{ t } [ message >quoted-lines "=\r\n" swap subseq? ] unit-test
{ 4 } [ message >quoted-lines string-lines length ] unit-test
{ "===o" } [ message >quoted-lines string-lines [ last ] "" map-as ] unit-test

View File

@ -34,13 +34,13 @@ IN: sequences.deep.tests
[ { { 1 2 3 } 4 } { { { 1 2 3 } 4 } 2 } deep-member? ] unit-test
{ f }
[ { 1 2 3 { 4 } } { 1 2 3 4 } deep-subseq? ] unit-test
[ { 1 2 3 4 } { 1 2 3 { 4 } } deep-subseq? ] unit-test
{ t }
[ { 1 2 3 4 } { 1 2 3 4 } deep-subseq? ] unit-test
{ t }
[ { { 1 2 3 4 } } { 1 2 3 4 } deep-subseq? ] unit-test
[ { 1 2 3 4 } { { 1 2 3 4 } } deep-subseq? ] unit-test
{ 3 } [
{ 1 { 2 3 { 4 } } 5 { { 6 } 7 } } 0 [

View File

@ -54,9 +54,9 @@ M: object branch? drop f ;
_ swap dup branch? [ member? ] [ 2drop f ] if
] deep-find >boolean ;
: deep-subseq? ( seq subseq -- ? )
'[
dup branch? [ _ subseq? ] [ drop f ] if
: deep-subseq? ( subseq seq -- ? )
swap '[
_ swap dup branch? [ subseq? ] [ 2drop f ] if
] deep-find >boolean ;
: deep-map! ( ... obj quot: ( ... elt -- ... elt' ) -- ... obj )

View File

@ -20,7 +20,7 @@ ERROR: not-a-vocab-root string ;
trim-tail-separators
vocab-roots get member? ;
: contains-dot? ( string -- ? ) ".." subseq? ;
: contains-dot? ( string -- ? ) ".." swap subseq? ;
: contains-separator? ( string -- ? ) [ path-separator? ] any? ;

View File

@ -138,7 +138,7 @@ PRIVATE>
{ [ dup "/" head? ] [ nip ] }
{ [ dup empty? ] [ drop ] }
{ [ over "/" tail? ] [ append ] }
{ [ over "/" start not ] [ nip ] }
{ [ "/" pick start not ] [ nip ] }
[ [ "/" split1-last drop "/" ] dip 3append ]
} cond ;

View File

@ -972,21 +972,20 @@ PRIVATE>
<PRIVATE
: (start) ( seq subseq n length -- seq subseq ? )
: (start) ( subseq seq n length -- subseq seq ? )
[
[ 3dup ] dip [ + ] keep
[ swap nth-unsafe ] bi-curry@ bi* =
[ 3dup ] dip [ + swap nth-unsafe ] keep rot nth-unsafe =
] all-integers? nip ; inline
PRIVATE>
: start* ( seq subseq n -- i )
2over [ length ] bi@ [ - 1 + ] keep
: start* ( subseq seq n -- i )
pick length [ pick length swap - 1 + ] keep
[ (start) ] curry (find-integer) 2nip ;
: start ( seq subseq -- i ) 0 start* ; inline
: start ( subseq seq -- i ) 0 start* ; inline
: subseq? ( seq subseq -- ? ) start >boolean ;
: subseq? ( subseq seq -- ? ) start >boolean ;
: drop-prefix ( seq1 seq2 -- slice1 slice2 )
2dup mismatch [ 2dup min-length ] unless*

View File

@ -30,7 +30,7 @@ PRIVATE>
: (split1) ( seq subseq snip-quot -- before after )
[
swap [
[ drop length ] [ swap start dup ] 2bi
[ drop length ] [ start dup ] 2bi
[ [ nip ] [ + ] 2bi t ]
[ 2drop f f f ]
if

View File

@ -12,20 +12,20 @@ vectors ;
{ "abc" } [ "ab" "c" append ] unit-test
{ "abc" } [ "a" "b" "c" 3append ] unit-test
{ 3 } [ "hola" "a" start ] unit-test
{ f } [ "hola" "x" start ] unit-test
{ 0 } [ "a" "" start ] unit-test
{ 3 } [ "a" "hola" start ] unit-test
{ f } [ "x" "hola" start ] unit-test
{ 0 } [ "" "a" start ] unit-test
{ 0 } [ "" "" start ] unit-test
{ 0 } [ "hola" "hola" start ] unit-test
{ 1 } [ "hola" "ol" start ] unit-test
{ f } [ "hola" "amigo" start ] unit-test
{ f } [ "hola" "holaa" start ] unit-test
{ 1 } [ "ol" "hola" start ] unit-test
{ f } [ "amigo" "hola" start ] unit-test
{ f } [ "holaa" "hola" start ] unit-test
{ "Beginning" } [ "Beginning and end" 9 head ] unit-test
{ f } [ CHAR: I "team" member? ] unit-test
{ t } [ "team" "ea" subseq? ] unit-test
{ f } [ "Factor" "actore" subseq? ] unit-test
{ t } [ "ea" "team" subseq? ] unit-test
{ f } [ "actore" "Factor" subseq? ] unit-test
{ "end" } [ "Beginning and end" 14 tail ] unit-test

View File

@ -440,8 +440,6 @@ MACRO: fortran-invoke ( return library function parameters -- quot )
return library function parameters return [ c:void ] unless* parse-arglist
[ \ fortran-invoke 5 [ ] nsequence ] dip define-declared ;
! TODO: I THINK THIS IS RIGHT FOR SUBSEQ?
SYNTAX: SUBROUTINE:
f current-library get scan-token ")" parse-tokens
[ "()" subseq? ] reject define-fortran-function ;

View File

@ -141,7 +141,7 @@ ERROR: undefined-find-nth m n seq quot ;
[ { [ name>> = ] [ closing?>> not ] } 1&& ] with find-all ;
: href-contains? ( str tag -- ? )
"href" attribute* [ swap subseq? ] [ 2drop f ] if ;
"href" attribute* [ subseq? ] [ 2drop f ] if ;
: find-hrefs ( vector -- vector' )
[ { [ name>> "a" = ] [ "href" attribute? ] } 1&& ] filter sift

View File

@ -17,7 +17,7 @@ default-8bit-encoding [ latin1 ] initialize
: prolog-encoding ( string -- iana-encoding )
'[
_ dup "encoding=" start
_ "encoding=" over start
10 + swap [ [ 1 - ] dip nth ] [ index-from ] [ swapd subseq ] 2tri
] [ drop "UTF-8" ] recover ;

View File

@ -246,7 +246,7 @@ GENERIC: lint ( obj -- seq )
M: object lint ( obj -- seq ) drop f ;
M: callable lint ( quot -- seq )
lint-definitions-keys get-global [ subseq? ] with filter ;
[ lint-definitions-keys get-global ] dip '[ _ subseq? ] filter ;
M: word lint ( word -- seq/f )
def>> [ callable? ] deep-filter [ lint ] map concat ;

View File

@ -227,7 +227,7 @@ CONSTANT: compass-directions H{
] if ;
: parse-weather ( str -- str' )
dup "VC" subseq? [ "VC" "" replace t ] [ f ] if
"VC" over subseq? [ "VC" "" replace t ] [ f ] if
[ (parse-weather) ]
[ [ " in the vicinity" append ] when ] bi* ;

View File

@ -80,7 +80,7 @@ SYMBOL: sieve
] each sieve get ;
: consecutive-under ( m limit -- n/f )
prime-tau-upto swap dup <repetition> start ;
prime-tau-upto [ dup <repetition> ] dip start ;
PRIVATE>

View File

@ -32,7 +32,7 @@ TUPLE: maxlicense max-count current-count times ;
: <maxlicense> ( -- max ) -1 0 V{ } clone \ maxlicense boa ; inline
: out? ( line -- ? ) "OUT" subseq? ; inline
: out? ( line -- ? ) [ "OUT" ] dip subseq? ; inline
: line-time ( line -- time ) " " split harvest fourth ; inline

View File

@ -16,6 +16,6 @@ IN: rosetta-code.web-scraping
: web-scraping-main ( -- )
"http://tycho.usno.navy.mil/cgi-bin/timer.pl" http-get nip
[ "UTC" start [ 9 - ] [ 1 - ] bi ] keep subseq print ;
[ "UTC" swap start [ 9 - ] [ 1 - ] bi ] keep subseq print ;
MAIN: web-scraping-main

View File

@ -187,10 +187,10 @@ HELP: start-all
{ "subseq" sequence } { "seq" sequence } { "indices" sequence } }
{ $description "Outputs the starting indices of the non-overlapping occurrences of " { $snippet "subseq" } " in " { $snippet "seq" } "." }
{ $examples
{ $example "USING: prettyprint sequences.extras ; \"ABABA\" \"ABA\" start-all ."
{ $example "USING: prettyprint sequences.extras ; \"ABA\" \"ABABA\" start-all ."
"{ 0 }"
}
{ $example "USING: prettyprint sequences.extras ; \"ABAABA\" \"ABA\" start-all ."
{ $example "USING: prettyprint sequences.extras ; \"ABA\" \"ABAABA\" start-all ."
"{ 0 3 }"
}
} ;
@ -200,7 +200,7 @@ HELP: start-all*
{ "subseq" sequence } { "seq" sequence } { "indices" sequence } }
{ $description "Outputs the starting indices of the possibly overlapping occurrences of " { $snippet "subseq" } " in " { $snippet "seq" } "." }
{ $examples
{ $example "USING: prettyprint sequences.extras ; \"ABABA\" \"ABA\" start-all* ."
{ $example "USING: prettyprint sequences.extras ; \"ABA\" \"ABABA\" start-all* ."
"{ 0 2 }"
} } ;
@ -209,7 +209,7 @@ HELP: count-subseq
{ "subseq" sequence } { "seq" sequence } { "n" integer } }
{ $description "Outputs the number of non-overlapping occurrences of " { $snippet "subseq" } " in " { $snippet "seq" } "." }
{ $examples
{ $example "USING: prettyprint sequences.extras ; \"ABABA\" \"ABA\" count-subseq ."
{ $example "USING: prettyprint sequences.extras ; \"ABA\" \"ABABA\" count-subseq ."
"1"
} } ;
@ -219,7 +219,7 @@ HELP: count-subseq*
{ "subseq" sequence } { "seq" sequence } { "n" integer } }
{ $description "Outputs the number of possibly overlapping occurrences of " { $snippet "subseq" } " in " { $snippet "seq" } "." }
{ $examples
{ $example "USING: prettyprint sequences.extras ; \"ABABA\" \"ABA\" count-subseq* ."
{ $example "USING: prettyprint sequences.extras ; \"ABA\" \"ABABA\" count-subseq* ."
"2"
} } ;

View File

@ -226,11 +226,11 @@ IN: sequences.extras.tests
{ 3/10 } [ 10 iota [ 3 < ] count* ] unit-test
{ { 0 } } [ "ABABA" "ABA" start-all ] unit-test
{ { 0 2 } } [ "ABABA" "ABA" start-all* ] unit-test
{ { 0 3 } } [ "ABAABA" "ABA" start-all ] unit-test
{ 1 } [ "ABABA" "ABA" count-subseq ] unit-test
{ 2 } [ "ABABA" "ABA" count-subseq* ] unit-test
{ { 0 } } [ "ABA" "ABABA" start-all ] unit-test
{ { 0 2 } } [ "ABA" "ABABA" start-all* ] unit-test
{ { 0 3 } } [ "ABA" "ABAABA" start-all ] unit-test
{ 1 } [ "ABA" "ABABA" count-subseq ] unit-test
{ 2 } [ "ABA" "ABABA" count-subseq* ] unit-test
{ 120000 } [ { 10 20 30 40 50 60 } 1 [ * ] 3 reduce-from ] unit-test

View File

@ -577,21 +577,21 @@ PRIVATE>
: map-find-last-index ( ... seq quot: ( ... elt index -- ... result/f ) -- ... result i elt )
[ find-last-index ] (map-find-index) ; inline
:: (start-all) ( seq subseq increment -- indices )
:: (start-all) ( subseq seq increment -- indices )
0
[ [ seq subseq ] dip start* dup ]
[ [ subseq seq ] dip start* dup ]
[ [ increment + ] keep ] produce nip ;
: start-all ( seq subseq -- indices )
dup length (start-all) ; inline
: start-all ( subseq seq -- indices )
over length (start-all) ; inline
: start-all* ( seq subseq -- indices )
: start-all* ( subseq seq -- indices )
1 (start-all) ; inline
: count-subseq ( seq subseq -- n )
: count-subseq ( subseq seq -- n )
start-all length ; inline
: count-subseq* ( seq subseq -- n )
: count-subseq* ( subseq seq -- n )
start-all* length ; inline
: map-zip ( quot: ( x -- y ) -- alist )

View File

@ -41,8 +41,8 @@ DEFER: name/values
parse-name [ parse-value ] dip associate ;
: name=value ( string -- remain term )
[ blank? ] trim dup ":`" subseq?
[ (name=value) ] [ f swap ] if ;
[ blank? ] trim
":`" over subseq? [ (name=value) ] [ f swap ] if ;
: name/values ( string -- remain terms )
[ dup { [ empty? not ] [ first CHAR: ` = not ] } 1&& ]