diff --git a/basis/compiler/cfg/copy-prop/copy-prop.factor b/basis/compiler/cfg/copy-prop/copy-prop.factor index 6919ba8b9b..23382c3dbe 100644 --- a/basis/compiler/cfg/copy-prop/copy-prop.factor +++ b/basis/compiler/cfg/copy-prop/copy-prop.factor @@ -63,7 +63,7 @@ M: insn update-insn rename-insn-uses t ; copies get dup assoc-empty? [ 2drop ] [ renamings set [ - instructions>> [ update-insn ] filter-here + instructions>> [ update-insn ] filter! drop ] each-basic-block ] if ; diff --git a/basis/compiler/cfg/dce/dce.factor b/basis/compiler/cfg/dce/dce.factor index b8735e224c..03a43d0ab7 100644 --- a/basis/compiler/cfg/dce/dce.factor +++ b/basis/compiler/cfg/dce/dce.factor @@ -117,5 +117,5 @@ M: insn live-insn? defs-vreg [ live-vreg? ] [ t ] if* ; dup [ [ instructions>> [ build-liveness-graph ] each ] each-basic-block ] [ [ instructions>> [ compute-live-vregs ] each ] each-basic-block ] - [ [ instructions>> [ live-insn? ] filter-here ] each-basic-block ] + [ [ instructions>> [ live-insn? ] filter! drop ] each-basic-block ] tri ; diff --git a/basis/compiler/cfg/linear-scan/allocation/allocation.factor b/basis/compiler/cfg/linear-scan/allocation/allocation.factor index ac32265e65..8951d7a1f1 100644 --- a/basis/compiler/cfg/linear-scan/allocation/allocation.factor +++ b/basis/compiler/cfg/linear-scan/allocation/allocation.factor @@ -42,7 +42,7 @@ IN: compiler.cfg.linear-scan.allocation : handle-sync-point ( n -- ) [ active-intervals get values ] dip - '[ [ _ spill-at-sync-point ] filter-here ] each ; + '[ [ _ spill-at-sync-point ] filter! drop ] each ; :: handle-progress ( n sync? -- ) n { diff --git a/basis/compiler/cfg/linear-scan/allocation/spilling/spilling.factor b/basis/compiler/cfg/linear-scan/allocation/spilling/spilling.factor index ec4fe02cfa..845cb14d5c 100644 --- a/basis/compiler/cfg/linear-scan/allocation/spilling/spilling.factor +++ b/basis/compiler/cfg/linear-scan/allocation/spilling/spilling.factor @@ -18,13 +18,13 @@ ERROR: bad-live-ranges interval ; : trim-before-ranges ( live-interval -- ) [ ranges>> ] [ uses>> last 1 + ] bi - [ '[ from>> _ <= ] filter-here ] + [ '[ from>> _ <= ] filter! drop ] [ swap last (>>to) ] 2bi ; : trim-after-ranges ( live-interval -- ) [ ranges>> ] [ uses>> first ] bi - [ '[ to>> _ >= ] filter-here ] + [ '[ to>> _ >= ] filter! drop ] [ swap first (>>from) ] 2bi ; @@ -114,7 +114,7 @@ ERROR: bad-live-ranges interval ; new start>> spill f ] [ drop t ] if ] [ drop t ] if - ] filter-here ; + ] filter! drop ; : spill-intersecting ( new reg -- ) ! Split and spill all active and inactive intervals diff --git a/basis/compiler/cfg/linear-scan/allocation/state/state.factor b/basis/compiler/cfg/linear-scan/allocation/state/state.factor index ea0879032d..4c825c9d7c 100644 --- a/basis/compiler/cfg/linear-scan/allocation/state/state.factor +++ b/basis/compiler/cfg/linear-scan/allocation/state/state.factor @@ -83,7 +83,7 @@ ERROR: register-already-used live-interval ; ! Moving intervals between active and inactive sets : process-intervals ( n symbol quots -- ) ! symbol stores an alist mapping register classes to vectors - [ get values ] dip '[ [ _ cond ] with filter-here ] with each ; inline + [ get values ] dip '[ [ _ cond ] with filter! drop ] with each ; inline : deactivate-intervals ( n -- ) ! Any active intervals which have ended are moved to handled diff --git a/basis/compiler/cfg/ssa/destruction/destruction.factor b/basis/compiler/cfg/ssa/destruction/destruction.factor index 071b5d4b20..d93045da55 100644 --- a/basis/compiler/cfg/ssa/destruction/destruction.factor +++ b/basis/compiler/cfg/ssa/destruction/destruction.factor @@ -102,7 +102,7 @@ M: ##phi prepare-insn [ rename-insn-defs ] [ rename-insn-uses ] [ [ useless-copy? ] [ ##phi? ] bi or not ] tri - ] filter-here + ] filter! drop ] each-basic-block ; : destruct-ssa ( cfg -- cfg' ) @@ -114,4 +114,4 @@ M: ##phi prepare-insn dup compute-live-ranges dup prepare-coalescing process-copies - dup perform-renaming ; \ No newline at end of file + dup perform-renaming ; diff --git a/basis/compiler/cfg/write-barrier/write-barrier.factor b/basis/compiler/cfg/write-barrier/write-barrier.factor index 0217055923..523f7c6d1c 100644 --- a/basis/compiler/cfg/write-barrier/write-barrier.factor +++ b/basis/compiler/cfg/write-barrier/write-barrier.factor @@ -37,7 +37,7 @@ M: insn eliminate-write-barrier drop t ; : write-barriers-step ( bb -- ) H{ } clone fresh-allocations set H{ } clone mutated-objects set - instructions>> [ eliminate-write-barrier ] filter-here ; + instructions>> [ eliminate-write-barrier ] filter! drop ; : eliminate-write-barriers ( cfg -- cfg' ) dup [ write-barriers-step ] each-basic-block ; diff --git a/basis/compiler/tree/cleanup/cleanup.factor b/basis/compiler/tree/cleanup/cleanup.factor index 1cd9589065..8ed83188e5 100644 --- a/basis/compiler/tree/cleanup/cleanup.factor +++ b/basis/compiler/tree/cleanup/cleanup.factor @@ -20,7 +20,7 @@ IN: compiler.tree.cleanup GENERIC: delete-node ( node -- ) M: #call-recursive delete-node - dup label>> calls>> [ node>> eq? not ] with filter-here ; + dup label>> calls>> [ node>> eq? not ] with filter! drop ; M: #return-recursive delete-node label>> f >>return drop ; diff --git a/core/assocs/assocs-docs.factor b/core/assocs/assocs-docs.factor index c1b9e2cb56..5a69df8cb4 100755 --- a/core/assocs/assocs-docs.factor +++ b/core/assocs/assocs-docs.factor @@ -97,7 +97,6 @@ ARTICLE: "assocs-sets" "Set-theoretic operations on assocs" assoc-union assoc-diff substitute - substitute-here extract-keys } { $see-also key? assoc-any? assoc-all? "sets" } ; @@ -348,12 +347,6 @@ HELP: assoc-diff { $description "Outputs an assoc consisting of all entries from " { $snippet "assoc1" } " whose key is not contained in " { $snippet "assoc2" } "." } ; -HELP: substitute-here -{ $values { "seq" "a mutable sequence" } { "assoc" assoc } } -{ $description "Replaces elements of " { $snippet "seq" } " which appear as keys in " { $snippet "assoc" } " with the corresponding values, acting as the identity on all other elements." } -{ $errors "Throws an error if " { $snippet "assoc" } " contains values whose types are not permissible in " { $snippet "seq" } "." } -{ $side-effects "seq" } ; - HELP: substitute { $values { "seq" sequence } { "assoc" assoc } { "newseq" sequence } } { $description "Creates a new sequence where elements of " { $snippet "seq" } " which appear as keys in " { $snippet "assoc" } " are replaced by the corresponding values, and all other elements are unchanged." } ; diff --git a/core/assocs/assocs.factor b/core/assocs/assocs.factor index 9e4a6e221e..6b66a79358 100755 --- a/core/assocs/assocs.factor +++ b/core/assocs/assocs.factor @@ -135,9 +135,6 @@ M: assoc assoc-clone-like ( assoc exemplar -- newassoc ) : assoc-diff ( assoc1 assoc2 -- diff ) [ nip key? not ] curry assoc-filter ; -: substitute-here ( seq assoc -- ) - substituter map! drop ; - : substitute ( seq assoc -- newseq ) substituter map ; diff --git a/core/hashtables/hashtables-tests.factor b/core/hashtables/hashtables-tests.factor index 54e58c0282..05cc27f5e8 100644 --- a/core/hashtables/hashtables-tests.factor +++ b/core/hashtables/hashtables-tests.factor @@ -155,11 +155,6 @@ H{ } "x" set ] { } make ] unit-test -[ { "one" "two" 3 } ] [ - { 1 2 3 } clone dup - H{ { 1 "one" } { 2 "two" } } substitute-here -] unit-test - [ { "one" "two" 3 } ] [ { 1 2 3 } H{ { 1 "one" } { 2 "two" } } substitute ] unit-test diff --git a/core/sequences/sequences-docs.factor b/core/sequences/sequences-docs.factor index 775734f0f7..6740b51d4d 100755 --- a/core/sequences/sequences-docs.factor +++ b/core/sequences/sequences-docs.factor @@ -430,8 +430,8 @@ HELP: filter-as { $values { "seq" sequence } { "quot" { $quotation "( elt -- ? )" } } { "exemplar" sequence } { "subseq" "a new sequence" } } { $description "Applies the quotation to each element in turn, and outputs a new sequence of the same type as " { $snippet "exemplar" } " containing the elements of the original sequence for which the quotation output a true value." } ; -HELP: filter-here -{ $values { "seq" "a resizable mutable sequence" } { "quot" { $quotation "( elt -- ? )" } } } +HELP: filter! +{ $values { "seq" "a resizable mutable sequence" } { "quot" { $quotation "( elt -- ? )" } } { "seq" "a resizable mutable sequence" } } { $description "Applies the quotation to each element in turn, and removes elements for which the quotation outputs a false value." } { $side-effects "seq" } ; @@ -1065,7 +1065,7 @@ HELP: harvest } } ; -{ filter filter-here sift harvest } related-words +{ filter filter! sift harvest } related-words HELP: set-first { $values @@ -1598,7 +1598,7 @@ ARTICLE: "sequences-destructive" "Destructive operations" remove-nth! delete-slice delete-all - filter-here + filter! } "Other destructive words:" { $subsections @@ -1620,7 +1620,7 @@ ARTICLE: "sequences-destructive" "Destructive operations" { { $link reverse } { $link reverse-here } } { { $link append } { $link push-all } } { { $link map } { $link map! } } - { { $link filter } { $link filter-here } } + { { $link filter } { $link filter! } } } { $heading "Related Articles" } { $subsections diff --git a/core/sequences/sequences-tests.factor b/core/sequences/sequences-tests.factor index 0acc1b7344..d25c62c561 100644 --- a/core/sequences/sequences-tests.factor +++ b/core/sequences/sequences-tests.factor @@ -59,10 +59,10 @@ IN: sequences.tests [ [ 3 ] ] [ [ 1 2 3 ] 2 [ swap < ] curry filter ] unit-test -[ V{ 1 2 3 } ] [ V{ 1 4 2 5 3 6 } clone [ [ 4 < ] filter-here ] keep ] unit-test -[ V{ 4 2 6 } ] [ V{ 1 4 2 5 3 6 } clone [ [ 2 mod 0 = ] filter-here ] keep ] unit-test +[ V{ 1 2 3 } ] [ V{ 1 4 2 5 3 6 } clone [ 4 < ] filter! ] unit-test +[ V{ 4 2 6 } ] [ V{ 1 4 2 5 3 6 } clone [ 2 mod 0 = ] filter! ] unit-test -[ V{ 3 } ] [ V{ 1 2 3 } clone [ 2 [ swap < ] curry filter-here ] keep ] unit-test +[ V{ 3 } ] [ V{ 1 2 3 } clone 2 [ swap < ] curry filter! ] unit-test [ "hello world how are you" ] [ { "hello" "world" "how" "are" "you" } " " join ] diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 940bfe0137..c74a7c3ad0 100755 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -619,24 +619,24 @@ M: slice equal? over slice? [ sequence= ] [ 2drop f ] if ; -: filter-here ( seq quot -- ) - swap [ 0 0 ] dip (filter-here) ; inline +: filter! ( seq quot -- seq ) + swap [ [ 0 0 ] dip (filter!) ] keep ; inline : remove! ( elt seq -- seq ) - [ [ = not ] with filter-here ] keep ; + [ = not ] with filter! ; : remove-eq! ( elt seq -- seq ) - [ [ eq? not ] with filter-here ] keep ; + [ eq? not ] with filter! ; : prefix ( seq elt -- newseq ) over [ over length 1 + ] dip [ diff --git a/core/source-files/errors/errors.factor b/core/source-files/errors/errors.factor index b240b6929e..ebacc90f63 100644 --- a/core/source-files/errors/errors.factor +++ b/core/source-files/errors/errors.factor @@ -80,7 +80,7 @@ SYMBOL: error-observers [ [ swap file>> = ] [ swap error-type = ] bi-curry* bi and not - ] 2curry filter-here + ] 2curry filter! drop notify-error-observers ; : delete-definition-errors ( definition -- ) diff --git a/misc/vim/syntax/factor.vim b/misc/vim/syntax/factor.vim index e13834f904..ef5046d6d6 100644 --- a/misc/vim/syntax/factor.vim +++ b/misc/vim/syntax/factor.vim @@ -50,10 +50,10 @@ syn keyword factorCompileDirective inline foldable recursive syn keyword factorKeyword boolean syn keyword factorKeyword or tuck 2bi 2tri while wrapper nip 4dip wrapper? bi* callstack>array both? hashcode die dupd callstack callstack? 3dup tri@ pick curry build ?execute 3bi prepose >boolean ?if clone eq? tri* ? = swapd call-clear 2over 2keep 3keep clear 2dup when not tuple? dup 2bi* 2tri* call tri-curry object bi@ do unless* if* loop bi-curry* drop when* assert= retainstack assert? -rot execute 2bi@ 2tri@ boa with either? 3drop bi curry? datastack until 3dip over 3curry roll tri-curry* swap tri-curry@ 2nip and throw set-retainstack bi-curry (clone) hashcode* compose spin 2dip if 3tri unless compose? tuple keep 2curry equal? set-datastack assert tri 2drop most boolean? identity-tuple? null new set-callstack dip bi-curry@ rot -roll xor identity-tuple boolean -syn keyword factorKeyword ?at assoc? assoc-clone-like assoc= delete-at* assoc-partition extract-keys new-assoc value? assoc-size map>assoc push-at assoc-like key? assoc-intersect assoc-refine update assoc-union assoc-combine at* assoc-empty? at+ set-at assoc-all? assoc-subset? assoc-hashcode change-at assoc-each assoc-diff zip values value-at rename-at inc-at enum? at cache assoc>map assoc assoc-map enum value-at* assoc-map-as >alist assoc-filter-as substitute-here clear-assoc assoc-stack maybe-set-at substitute assoc-filter 2cache delete-at assoc-find keys assoc-any? unzip +syn keyword factorKeyword ?at assoc? assoc-clone-like assoc= delete-at* assoc-partition extract-keys new-assoc value? assoc-size map>assoc push-at assoc-like key? assoc-intersect assoc-refine update assoc-union assoc-combine at* assoc-empty? at+ set-at assoc-all? assoc-subset? assoc-hashcode change-at assoc-each assoc-diff zip values value-at rename-at inc-at enum? at cache assoc>map assoc assoc-map enum value-at* assoc-map-as >alist assoc-filter-as clear-assoc assoc-stack maybe-set-at substitute assoc-filter 2cache delete-at assoc-find keys assoc-any? unzip syn keyword factorKeyword case execute-effect no-cond no-case? 3cleave>quot 2cleave cond>quot wrong-values? no-cond? cleave>quot no-case case>quot 3cleave wrong-values to-fixed-point alist>quot case-find cond cleave call-effect 2cleave>quot recursive-hashcode linear-case-quot spread spread>quot syn keyword factorKeyword byte-array>bignum sgn >bignum next-float number= each-integer next-power-of-2 ?1+ fp-special? imaginary-part mod recip float>bits rational >float number? 2^ bignum? integer fixnum? neg fixnum sq bignum fp-snan? fp-infinity? denominator (all-integers?) times find-last-integer (each-integer) bit? * + fp-bitwise= - fp-qnan? / power-of-2? >= bitand find-integer complex < log2 > integer? real number bits>double double>bits bitor 2/ zero? rem fp-nan-payload all-integers? (find-integer) real-part prev-float align bits>float float? shift float fp-nan? abs bitxor ratio? even? <= /mod odd? >integer ratio rational? bitnot real? >fixnum complex? /i numerator /f -syn keyword factorKeyword append assert-sequence= find-last-from trim-head-slice clone-like 3sequence assert-sequence? map-as filter-here last-index-from reversed index-from cut* pad-tail (indices) concat-as remove-eq but-last snip trim-tail nths nth 2pusher sequence slice? partition remove-nth tail-slice empty? tail* if-empty find-from virtual-sequence? member? set-length remove-eq! drop-prefix unclip iota unclip-last-slice bounds-error? sequence-hashcode-step map start midpoint@ rest-slice prepend fourth sift delete sigma new-sequence follow like remove-nth! first4 1sequence reverse slice unless-empty padding virtual@ repetition? set-last index 4sequence max-length set-second immutable-sequence first2 first3 replicate-as reduce-index unclip-slice supremum insert-nth trim-tail-slice tail 3append short count suffix concat flip filter sum immutable? 2sequence map-integers delete-all start* indices snip-slice check-slice sequence? head map-find reduce append-as reverse-here sequence= halves collapse-slice interleave 2map binary-reduce virtual-seq slice-error? product bounds-check? bounds-check harvest immutable find produce remove pad-head last replicate set-fourth shorten reversed? map-find-last 3map-as 2unclip-slice shorter? 3map find-last head-slice pop* 2map-as tail-slice* but-last-slice 2map-reduce iota? accumulate each pusher cut-slice new-resizable each-index head-slice* 2reverse-each sequence-hashcode memq? pop set-nth ?nth second map! join when-empty accumulator immutable-sequence? all? 3append-as virtual-sequence subseq? push-either new-like length last-index push-if 2all? lengthen assert-sequence copy map-reduce move third first 3each tail? set-first prefix bounds-error any? trim-slice exchange surround 2reduce cut change-nth min-length set-third produce-as push-all head? delete-slice rest sum-lengths 2each head* infimum glue slice-error subseq replace-slice push repetition map-index trim-head unclip-last mismatch trim +syn keyword factorKeyword append assert-sequence= find-last-from trim-head-slice clone-like 3sequence assert-sequence? map-as filter! last-index-from reversed index-from cut* pad-tail (indices) concat-as remove-eq but-last snip trim-tail nths nth 2pusher sequence slice? partition remove-nth tail-slice empty? tail* if-empty find-from virtual-sequence? member? set-length remove-eq! drop-prefix unclip iota unclip-last-slice bounds-error? sequence-hashcode-step map start midpoint@ rest-slice prepend fourth sift delete sigma new-sequence follow like remove-nth! first4 1sequence reverse slice unless-empty padding virtual@ repetition? set-last index 4sequence max-length set-second immutable-sequence first2 first3 replicate-as reduce-index unclip-slice supremum insert-nth trim-tail-slice tail 3append short count suffix concat flip filter sum immutable? 2sequence map-integers delete-all start* indices snip-slice check-slice sequence? head map-find reduce append-as reverse-here sequence= halves collapse-slice interleave 2map binary-reduce virtual-seq slice-error? product bounds-check? bounds-check harvest immutable find produce remove pad-head last replicate set-fourth shorten reversed? map-find-last 3map-as 2unclip-slice shorter? 3map find-last head-slice pop* 2map-as tail-slice* but-last-slice 2map-reduce iota? accumulate each pusher cut-slice new-resizable each-index head-slice* 2reverse-each sequence-hashcode memq? pop set-nth ?nth second map! join when-empty accumulator immutable-sequence? all? 3append-as virtual-sequence subseq? push-either new-like length last-index push-if 2all? lengthen assert-sequence copy map-reduce move third first 3each tail? set-first prefix bounds-error any? trim-slice exchange surround 2reduce cut change-nth min-length set-third produce-as push-all head? delete-slice rest sum-lengths 2each head* infimum glue slice-error subseq replace-slice push repetition map-index trim-head unclip-last mismatch trim syn keyword factorKeyword global +@ change set-namestack change-global init-namespaces on off set-global namespace set with-scope bind with-variable inc dec counter initialize namestack get get-global make-assoc syn keyword factorKeyword 2array 3array pair >array 1array 4array pair? array resize-array array? syn keyword factorKeyword +character+ bad-seek-type? readln stream-seek read print with-output-stream contents write1 stream-write1 stream-copy stream-element-type with-input-stream stream-print stream-read stream-contents bl seek-output bad-seek-type nl stream-nl write flush stream-lines +byte+ stream-flush read1 seek-absolute? stream-read1 lines stream-readln stream-read-until each-line seek-end with-output-stream* seek-absolute with-streams seek-input seek-relative? input-stream stream-write read-partial seek-end? seek-relative error-stream read-until with-input-stream* with-streams* each-block output-stream stream-read-partial