remove non-primitive-related uses of tuck from basis

db4
Joe Groff 2009-11-05 17:03:24 -06:00
parent 9ec0c3e923
commit 61d579360d
22 changed files with 60 additions and 54 deletions

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: tools.test core-text core-text.fonts core-foundation USING: tools.test core-text core-text.fonts core-foundation
core-foundation.dictionaries destructors arrays kernel generalizations core-foundation.dictionaries destructors arrays kernel generalizations
math accessors core-foundation.utilities combinators hashtables colors locals math accessors core-foundation.utilities combinators hashtables colors
colors.constants ; colors.constants ;
IN: core-text.tests IN: core-text.tests
@ -18,10 +18,11 @@ IN: core-text.tests
] with-destructors ] with-destructors
] unit-test ] unit-test
: test-typographic-bounds ( string font -- ? ) :: test-typographic-bounds ( string font -- ? )
[ [
test-font &CFRelease tuck COLOR: white <CTLine> &CFRelease font test-font &CFRelease :> ctfont
compute-line-metrics { string ctfont COLOR: white <CTLine> &CFRelease :> ctline
ctfont ctline compute-line-metrics {
[ width>> float? ] [ width>> float? ]
[ ascent>> float? ] [ ascent>> float? ]
[ descent>> float? ] [ descent>> float? ]

View File

@ -70,11 +70,12 @@ IN: csv.tests
"can write csv too!" "can write csv too!"
[ "foo1,bar1\nfoo2,bar2\n" ] [ "foo1,bar1\nfoo2,bar2\n" ]
[ { { "foo1" "bar1" } { "foo2" "bar2" } } <string-writer> tuck write-csv >string ] named-unit-test [ { { "foo1" "bar1" } { "foo2" "bar2" } } <string-writer> [ write-csv ] keep >string ] named-unit-test
"escapes quotes commas and newlines when writing" "escapes quotes commas and newlines when writing"
[ "\"fo\"\"o1\",bar1\n\"fo\no2\",\"b,ar2\"\n" ] [ "\"fo\"\"o1\",bar1\n\"fo\no2\",\"b,ar2\"\n" ]
[ { { "fo\"o1" "bar1" } { "fo\no2" "b,ar2" } } <string-writer> tuck write-csv >string ] named-unit-test ! " [ { { "fo\"o1" "bar1" } { "fo\no2" "b,ar2" } } <string-writer> [ write-csv ] keep >string ] named-unit-test ! "
[ { { "writing" "some" "csv" "tests" } } ] [ { { "writing" "some" "csv" "tests" } } ]
[ [

View File

@ -4,7 +4,7 @@ USING: alien arrays assocs classes compiler db hashtables
io.files kernel math math.parser namespaces prettyprint fry io.files kernel math math.parser namespaces prettyprint fry
sequences strings classes.tuple alien.c-types continuations sequences strings classes.tuple alien.c-types continuations
db.sqlite.lib db.sqlite.ffi db.tuples words db.types combinators db.sqlite.lib db.sqlite.ffi db.tuples words db.types combinators
math.intervals io nmake accessors vectors math.ranges random math.intervals io locals nmake accessors vectors math.ranges random
math.bitwise db.queries destructors db.tuples.private interpolate math.bitwise db.queries destructors db.tuples.private interpolate
io.streams.string make db.private sequences.deep io.streams.string make db.private sequences.deep
db.errors.sqlite ; db.errors.sqlite ;
@ -85,12 +85,11 @@ M: literal-bind sqlite-bind-conversion ( tuple literal-bind -- array )
nip [ key>> ] [ value>> ] [ type>> ] tri nip [ key>> ] [ value>> ] [ type>> ] tri
<sqlite-low-level-binding> ; <sqlite-low-level-binding> ;
M: generator-bind sqlite-bind-conversion ( tuple generate-bind -- array ) M:: generator-bind sqlite-bind-conversion ( tuple generate-bind -- array )
tuck generate-bind generator-singleton>> eval-generator :> obj
[ generator-singleton>> eval-generator tuck ] [ slot-name>> ] bi generate-bind slot-name>> :> name
rot set-slot-named obj name tuple set-slot-named
[ [ key>> ] [ type>> ] bi ] dip generate-bind key>> obj generate-bind type>> <sqlite-low-level-binding> ;
swap <sqlite-low-level-binding> ;
M: sqlite-statement bind-tuple ( tuple statement -- ) M: sqlite-statement bind-tuple ( tuple statement -- )
[ [

View File

@ -59,7 +59,6 @@ $nl
{ { $link literalize } { $snippet ": literalize '[ _ ] ;" } } { { $link literalize } { $snippet ": literalize '[ _ ] ;" } }
{ { $link curry } { $snippet ": curry '[ _ @ ] ;" } } { { $link curry } { $snippet ": curry '[ _ @ ] ;" } }
{ { $link compose } { $snippet ": compose '[ @ @ ] ;" } } { { $link compose } { $snippet ": compose '[ @ @ ] ;" } }
{ { $link bi@ } { $snippet ": bi@ tuck '[ _ @ _ @ ] call ;" } }
} ; } ;
ARTICLE: "fry.philosophy" "Fried quotation philosophy" ARTICLE: "fry.philosophy" "Fried quotation philosophy"

View File

@ -75,9 +75,8 @@ SYMBOLS:
get-controllers [ product-id = ] with filter ; get-controllers [ product-id = ] with filter ;
: find-controller-instance ( product-id instance-id -- controller/f ) : find-controller-instance ( product-id instance-id -- controller/f )
get-controllers [ get-controllers [
tuck
[ product-id = ] [ product-id = ]
[ instance-id = ] 2bi* and [ instance-id = ] bi-curry bi* and
] with with find nip ; ] with with find nip ;
TUPLE: keyboard-state keys ; TUPLE: keyboard-state keys ;

View File

@ -295,7 +295,7 @@ MEMO: dct-matrix-blas ( -- m ) dct-matrix >float-blas-matrix ;
binary [ binary [
[ [
{ HEX: FF } read-until { HEX: FF } read-until
read1 tuck HEX: 00 = and read1 [ HEX: 00 = and ] keep swap
] ]
[ drop ] produce [ drop ] produce
swap >marker { EOI } assert= swap >marker { EOI } assert=

View File

@ -8,7 +8,7 @@ strings accessors destructors ;
[ length ] dip buffer-reset ; [ length ] dip buffer-reset ;
: string>buffer ( string -- buffer ) : string>buffer ( string -- buffer )
dup length <buffer> tuck buffer-set ; dup length <buffer> [ buffer-set ] keep ;
: buffer-read-all ( buffer -- byte-array ) : buffer-read-all ( buffer -- byte-array )
[ [ pos>> ] [ ptr>> ] bi <displaced-alien> ] [ [ pos>> ] [ ptr>> ] bi <displaced-alien> ]

View File

@ -151,12 +151,16 @@ PRIVATE>
M: winnt file-system-info ( path -- file-system-info ) M: winnt file-system-info ( path -- file-system-info )
normalize-path root-directory (file-system-info) ; normalize-path root-directory (file-system-info) ;
: volume>paths ( string -- array ) :: volume>paths ( string -- array )
16384 <ushort-array> tuck dup length 16384 :> names-buf-length
0 <uint> dup [ GetVolumePathNamesForVolumeName 0 = ] dip swap [ names-buf-length <ushort-array> :> names
win32-error-string throw 0 <uint> :> names-length
string names names-buf-length names-length GetVolumePathNamesForVolumeName :> ret
ret 0 = [
ret win32-error-string throw
] [ ] [
*uint "ushort" heap-size * head names names-length *uint "ushort" heap-size * head
utf16n alien>string CHAR: \0 split utf16n alien>string CHAR: \0 split
] if ; ] if ;
@ -166,13 +170,16 @@ M: winnt file-system-info ( path -- file-system-info )
FindFirstVolume dup win32-error=0/f FindFirstVolume dup win32-error=0/f
[ utf16n alien>string ] dip ; [ utf16n alien>string ] dip ;
: find-next-volume ( handle -- string/f ) :: find-next-volume ( handle -- string/f )
MAX_PATH 1 + [ <ushort-array> tuck ] keep MAX_PATH 1 + :> buf-length
FindNextVolume 0 = [ buf-length <ushort-array> :> buf
handle buf buf-length FindNextVolume :> ret
ret 0 = [
GetLastError ERROR_NO_MORE_FILES = GetLastError ERROR_NO_MORE_FILES =
[ drop f ] [ win32-error-string throw ] if [ drop f ] [ win32-error-string throw ] if
] [ ] [
utf16n alien>string buf utf16n alien>string
] if ; ] if ;
: find-volumes ( -- array ) : find-volumes ( -- array )

View File

@ -132,7 +132,7 @@ M: windows run-process* ( process -- handle )
current-directory get absolute-path cd current-directory get absolute-path cd
dup make-CreateProcess-args dup make-CreateProcess-args
tuck fill-redirection [ fill-redirection ] keep
dup call-CreateProcess dup call-CreateProcess
lpProcessInformation>> lpProcessInformation>>
] with-destructors ; ] with-destructors ;

View File

@ -114,7 +114,7 @@ M: lazy-until car ( lazy-until -- car )
cons>> car ; cons>> car ;
M: lazy-until cdr ( lazy-until -- cdr ) M: lazy-until cdr ( lazy-until -- cdr )
[ cons>> unswons ] keep quot>> tuck call( elt -- ? ) [ quot>> ] [ cons>> unswons ] bi over call( elt -- ? )
[ 2drop nil ] [ luntil ] if ; [ 2drop nil ] [ luntil ] if ;
M: lazy-until nil? ( lazy-until -- ? ) M: lazy-until nil? ( lazy-until -- ? )

View File

@ -96,9 +96,9 @@ C: <combo> combo
initial-values [ over 0 > ] [ next-values ] produce initial-values [ over 0 > ] [ next-values ] produce
[ 3drop ] dip ; [ 3drop ] dip ;
: combination-indices ( m combo -- seq ) :: combination-indices ( m combo -- seq )
[ tuck dual-index combinadic ] keep combo m combo dual-index combinadic
seq>> length 1 - swap [ - ] with map ; combo seq>> length 1 - swap [ - ] with map ;
: apply-combination ( m combo -- seq ) : apply-combination ( m combo -- seq )
[ combination-indices ] keep seq>> nths ; [ combination-indices ] keep seq>> nths ;

View File

@ -79,7 +79,7 @@ IN: math.intervals.tests
[ t ] [ 1 2 [a,b] dup empty-interval interval-union = ] unit-test [ t ] [ 1 2 [a,b] dup empty-interval interval-union = ] unit-test
[ t ] [ empty-interval 1 2 [a,b] tuck interval-union = ] unit-test [ t ] [ 1 2 [a,b] empty-interval over interval-union = ] unit-test
[ t ] [ [ t ] [
0 1 (a,b) 0 1 [a,b] interval-union 0 1 [a,b] = 0 1 (a,b) 0 1 [a,b] interval-union 0 1 [a,b] =
@ -250,7 +250,7 @@ IN: math.intervals.tests
dup full-interval eq? [ dup full-interval eq? [
drop 32 random-bits 31 2^ - drop 32 random-bits 31 2^ -
] [ ] [
dup to>> first over from>> first tuck - random + [ ] [ from>> first ] [ to>> first ] tri over - random +
2dup swap interval-contains? [ 2dup swap interval-contains? [
nip nip
] [ ] [

View File

@ -58,7 +58,7 @@ M: persistent-vector nth-unsafe
[ 2array ] [ drop level>> 1 + ] 2bi node boa ; [ 2array ] [ drop level>> 1 + ] 2bi node boa ;
: new-child ( new-child node -- node' expansion/f ) : new-child ( new-child node -- node' expansion/f )
dup full? [ tuck level>> 1node ] [ node-add f ] if ; dup full? [ [ level>> 1node ] keep swap ] [ node-add f ] if ;
: new-last ( val seq -- seq' ) : new-last ( val seq -- seq' )
[ length 1 - ] keep new-nth ; [ length 1 - ] keep new-nth ;
@ -70,7 +70,7 @@ M: persistent-vector nth-unsafe
dup level>> 1 = [ dup level>> 1 = [
new-child new-child
] [ ] [
tuck children>> last (ppush-new-tail) [ nip ] 2keep children>> last (ppush-new-tail)
[ swap new-child ] [ swap node-set-last f ] ?if [ swap new-child ] [ swap node-set-last f ] ?if
] if ; ] if ;

View File

@ -25,7 +25,7 @@ IN: regexp.dfa
] unless ; ] unless ;
: epsilon-table ( states nfa -- table ) : epsilon-table ( states nfa -- table )
[ H{ } clone tuck ] dip [ [ H{ } clone ] dip over ] dip
'[ _ _ t epsilon-loop ] each ; '[ _ _ t epsilon-loop ] each ;
: find-epsilon-closure ( states nfa -- dfa-state ) : find-epsilon-closure ( states nfa -- dfa-state )

View File

@ -85,7 +85,7 @@ IN: regexp.minimize
'[ _ delete-duplicates ] change-transitions ; '[ _ delete-duplicates ] change-transitions ;
: combine-state-transitions ( hash -- hash ) : combine-state-transitions ( hash -- hash )
H{ } clone tuck '[ [ H{ } clone ] dip over '[
_ [ 2array <or-class> ] change-at _ [ 2array <or-class> ] change-at
] assoc-each [ swap ] assoc-map ; ] assoc-each [ swap ] assoc-map ;

View File

@ -22,8 +22,7 @@ IN: suffix-arrays
: <funky-slice> ( from/f to/f seq -- slice ) : <funky-slice> ( from/f to/f seq -- slice )
[ [
tuck [ drop 0 or ] [ length or ] bi-curry bi*
[ drop 0 or ] [ length or ] 2bi*
[ min ] keep [ min ] keep
] keep <slice> ; inline ] keep <slice> ; inline

View File

@ -98,7 +98,7 @@ M: bad-developer-name summary
[ main-file-string ] dip utf8 set-file-contents ; [ main-file-string ] dip utf8 set-file-contents ;
: scaffold-main ( vocab-root vocab -- ) : scaffold-main ( vocab-root vocab -- )
tuck ".factor" vocab-root/vocab/suffix>path scaffolding? [ [ ".factor" vocab-root/vocab/suffix>path ] keep swap scaffolding? [
set-scaffold-main-file set-scaffold-main-file
] [ ] [
2drop 2drop

View File

@ -20,8 +20,9 @@ TUPLE: node value children ;
] [ ] [
[ [
[ children>> swap first head-slice % ] [ children>> swap first head-slice % ]
[ tuck traverse-step traverse-to-path ] [ nip ]
2bi [ traverse-step traverse-to-path ]
2tri
] make-node ] make-node
] if ] if
] if ; ] if ;
@ -35,7 +36,9 @@ TUPLE: node value children ;
] [ ] [
[ [
[ traverse-step traverse-from-path ] [ traverse-step traverse-from-path ]
[ tuck children>> swap first 1 + tail-slice % ] 2bi [ nip ]
[ children>> swap first 1 + tail-slice % ]
2tri
] make-node ] make-node
] if ] if
] if ; ] if ;

View File

@ -23,7 +23,7 @@ GENERIC: group-struct ( obj -- group/f )
gr_mem>> utf8 alien>strings ; gr_mem>> utf8 alien>strings ;
: (group-struct) ( id -- group-struct id group-struct byte-array length void* ) : (group-struct) ( id -- group-struct id group-struct byte-array length void* )
\ unix:group <struct> tuck 4096 [ \ unix:group <struct> ] dip over 4096
[ <byte-array> ] keep f <void*> ; [ <byte-array> ] keep f <void*> ;
: check-group-struct ( group-struct ptr -- group-struct/f ) : check-group-struct ( group-struct ptr -- group-struct/f )

View File

@ -110,7 +110,7 @@ ERROR: mutually-recursive-rulesets ruleset ;
dup [ glob-matches? ] [ 2drop f ] if ; dup [ glob-matches? ] [ 2drop f ] if ;
: suitable-mode? ( file-name first-line mode -- ? ) : suitable-mode? ( file-name first-line mode -- ? )
tuck first-line-glob>> ?glob-matches [ nip ] 2keep first-line-glob>> ?glob-matches
[ 2drop t ] [ file-name-glob>> ?glob-matches ] if ; [ 2drop t ] [ file-name-glob>> ?glob-matches ] if ;
: find-mode ( file-name first-line -- mode ) : find-mode ( file-name first-line -- mode )

View File

@ -86,7 +86,7 @@ M: regexp text-matches?
[ >string ] dip first-match dup [ to>> ] when ; [ >string ] dip first-match dup [ to>> ] when ;
: rule-start-matches? ( rule -- match-count/f ) : rule-start-matches? ( rule -- match-count/f )
dup start>> tuck swap can-match-here? [ [ start>> dup ] keep can-match-here? [
rest-of-line swap text>> text-matches? rest-of-line swap text>> text-matches?
] [ ] [
drop f drop f
@ -96,7 +96,7 @@ M: regexp text-matches?
dup mark-following-rule? [ dup mark-following-rule? [
dup start>> swap can-match-here? 0 and dup start>> swap can-match-here? 0 and
] [ ] [
dup end>> tuck swap can-match-here? [ [ end>> dup ] keep can-match-here? [
rest-of-line rest-of-line
swap text>> context get end>> or swap text>> context get end>> or
text-matches? text-matches?
@ -170,7 +170,7 @@ M: seq-rule handle-rule-start
?end-rule ?end-rule
mark-token mark-token
add-remaining-token add-remaining-token
tuck body-token>> next-token, [ body-token>> next-token, ] keep
delegate>> [ push-context ] when* ; delegate>> [ push-context ] when* ;
UNION: abstract-span-rule span-rule eol-span-rule ; UNION: abstract-span-rule span-rule eol-span-rule ;
@ -179,7 +179,7 @@ M: abstract-span-rule handle-rule-start
?end-rule ?end-rule
mark-token mark-token
add-remaining-token add-remaining-token
tuck rule-match-token* next-token, [ rule-match-token* next-token, ] keep
! ... end subst ... ! ... end subst ...
dup context get (>>in-rule) dup context get (>>in-rule)
delegate>> push-context ; delegate>> push-context ;
@ -190,7 +190,7 @@ M: span-rule handle-rule-end
M: mark-following-rule handle-rule-start M: mark-following-rule handle-rule-start
?end-rule ?end-rule
mark-token add-remaining-token mark-token add-remaining-token
tuck rule-match-token* next-token, [ rule-match-token* next-token, ] keep
f context get (>>end) f context get (>>end)
context get (>>in-rule) ; context get (>>in-rule) ;

View File

@ -21,7 +21,6 @@ HELP: 2over $shuffle ;
HELP: pick ( x y z -- x y z x ) $shuffle ; HELP: pick ( x y z -- x y z x ) $shuffle ;
HELP: swap ( x y -- y x ) $shuffle ; HELP: swap ( x y -- y x ) $shuffle ;
HELP: spin $complex-shuffle ;
HELP: rot ( x y z -- y z x ) $complex-shuffle ; HELP: rot ( x y z -- y z x ) $complex-shuffle ;
HELP: -rot ( x y z -- z x y ) $complex-shuffle ; HELP: -rot ( x y z -- z x y ) $complex-shuffle ;
HELP: dupd ( x y -- x x y ) $complex-shuffle ; HELP: dupd ( x y -- x x y ) $complex-shuffle ;
@ -828,7 +827,6 @@ $nl
swapd swapd
rot rot
-rot -rot
spin
} ; } ;
ARTICLE: "shuffle-words" "Shuffle words" ARTICLE: "shuffle-words" "Shuffle words"