delete-nth -> remove-nth!
parent
f5a0a8b6e1
commit
951e3e9c83
|
@ -103,7 +103,7 @@ ERROR: bad-live-ranges interval ;
|
||||||
! most one) are split and spilled and removed from the inactive
|
! most one) are split and spilled and removed from the inactive
|
||||||
! set.
|
! set.
|
||||||
new vreg>> active-intervals-for [ [ reg>> reg = ] find swap dup ] keep
|
new vreg>> active-intervals-for [ [ reg>> reg = ] find swap dup ] keep
|
||||||
'[ _ delete-nth new start>> spill ] [ 2drop ] if ;
|
'[ _ remove-nth! drop new start>> spill ] [ 2drop ] if ;
|
||||||
|
|
||||||
:: spill-intersecting-inactive ( new reg -- )
|
:: spill-intersecting-inactive ( new reg -- )
|
||||||
! Any inactive intervals using 'reg' are split and spilled
|
! Any inactive intervals using 'reg' are split and spilled
|
||||||
|
@ -141,4 +141,4 @@ ERROR: bad-live-ranges interval ;
|
||||||
{ [ 2dup spill-new? ] [ spill-new ] }
|
{ [ 2dup spill-new? ] [ spill-new ] }
|
||||||
{ [ 2dup register-available? ] [ spill-available ] }
|
{ [ 2dup register-available? ] [ spill-available ] }
|
||||||
[ spill-partially-available ]
|
[ spill-partially-available ]
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
|
@ -96,7 +96,7 @@ HELP: delete-random
|
||||||
{ $values
|
{ $values
|
||||||
{ "seq" sequence }
|
{ "seq" sequence }
|
||||||
{ "elt" object } }
|
{ "elt" object } }
|
||||||
{ $description "Deletes a random number from a sequence using " { $link delete-nth } " and returns the deleted object." } ;
|
{ $description "Deletes a random number from a sequence using " { $link remove-nth! } " and returns the deleted object." } ;
|
||||||
|
|
||||||
ARTICLE: "random-protocol" "Random protocol"
|
ARTICLE: "random-protocol" "Random protocol"
|
||||||
"A random number generator must implement one of these two words:"
|
"A random number generator must implement one of these two words:"
|
||||||
|
|
|
@ -82,7 +82,7 @@ PRIVATE>
|
||||||
'[ _ dup random _ _ next-sample ] replicate ;
|
'[ _ dup random _ _ next-sample ] replicate ;
|
||||||
|
|
||||||
: delete-random ( seq -- elt )
|
: delete-random ( seq -- elt )
|
||||||
[ length random-integer ] keep [ nth ] 2keep delete-nth ;
|
[ length random-integer ] keep [ nth ] 2keep remove-nth! drop ;
|
||||||
|
|
||||||
: with-random ( tuple quot -- )
|
: with-random ( tuple quot -- )
|
||||||
random-generator swap with-variable ; inline
|
random-generator swap with-variable ; inline
|
||||||
|
|
|
@ -61,7 +61,7 @@ PRIVATE>
|
||||||
pick sizes>> push add-gadget ;
|
pick sizes>> push add-gadget ;
|
||||||
|
|
||||||
M: track remove-gadget
|
M: track remove-gadget
|
||||||
[ [ children>> index ] [ sizes>> ] bi delete-nth ]
|
[ [ children>> index ] [ sizes>> ] bi remove-nth! drop ]
|
||||||
[ call-next-method ] 2bi ;
|
[ call-next-method ] 2bi ;
|
||||||
|
|
||||||
: clear-track ( track -- ) [ sizes>> delete-all ] [ clear-gadget ] bi ;
|
: clear-track ( track -- ) [ sizes>> delete-all ] [ clear-gadget ] bi ;
|
||||||
|
|
|
@ -34,7 +34,7 @@ SYMBOL: windows
|
||||||
: raised-window ( world -- )
|
: raised-window ( world -- )
|
||||||
windows get-global
|
windows get-global
|
||||||
[ [ second eq? ] with find drop ] keep
|
[ [ second eq? ] with find drop ] keep
|
||||||
[ nth ] [ delete-nth ] [ nip ] 2tri push ;
|
[ nth ] [ remove-nth! drop ] [ nip ] 2tri push ;
|
||||||
|
|
||||||
: focus-gestures ( new old -- )
|
: focus-gestures ( new old -- )
|
||||||
drop-prefix <reversed>
|
drop-prefix <reversed>
|
||||||
|
|
|
@ -66,7 +66,7 @@ M: attrs clear-assoc
|
||||||
f >>alist drop ;
|
f >>alist drop ;
|
||||||
M: attrs delete-at
|
M: attrs delete-at
|
||||||
[ nip ] [ attr@ drop ] 2bi
|
[ nip ] [ attr@ drop ] 2bi
|
||||||
[ swap alist>> delete-nth ] [ drop ] if* ;
|
[ swap alist>> remove-nth! drop ] [ drop ] if* ;
|
||||||
|
|
||||||
M: attrs clone
|
M: attrs clone
|
||||||
alist>> clone <attrs> ;
|
alist>> clone <attrs> ;
|
||||||
|
|
|
@ -28,7 +28,7 @@ ARTICLE: "enums" "Enumerations"
|
||||||
HELP: enum
|
HELP: enum
|
||||||
{ $class-description "An associative structure which wraps a sequence and maps integers to the corresponding elements of the sequence."
|
{ $class-description "An associative structure which wraps a sequence and maps integers to the corresponding elements of the sequence."
|
||||||
$nl
|
$nl
|
||||||
"Enumerations are mutable; note that deleting a key calls " { $link delete-nth } ", which results in all subsequent elements being shifted down." } ;
|
"Enumerations are mutable; note that deleting a key calls " { $link remove-nth! } ", which results in all subsequent elements being shifted down." } ;
|
||||||
|
|
||||||
HELP: <enum>
|
HELP: <enum>
|
||||||
{ $values { "seq" sequence } { "enum" enum } }
|
{ $values { "seq" sequence } { "enum" enum } }
|
||||||
|
|
|
@ -195,7 +195,7 @@ M: sequence clear-assoc delete-all ; inline
|
||||||
|
|
||||||
M: sequence delete-at
|
M: sequence delete-at
|
||||||
[ nip ] [ search-alist nip ] 2bi
|
[ nip ] [ search-alist nip ] 2bi
|
||||||
[ swap delete-nth ] [ drop ] if* ;
|
[ swap remove-nth! drop ] [ drop ] if* ;
|
||||||
|
|
||||||
M: sequence assoc-size length ; inline
|
M: sequence assoc-size length ; inline
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ M: enum at*
|
||||||
|
|
||||||
M: enum set-at seq>> set-nth ; inline
|
M: enum set-at seq>> set-nth ; inline
|
||||||
|
|
||||||
M: enum delete-at seq>> delete-nth ; inline
|
M: enum delete-at seq>> remove-nth! drop ; inline
|
||||||
|
|
||||||
M: enum >alist ( enum -- alist )
|
M: enum >alist ( enum -- alist )
|
||||||
seq>> [ length ] keep zip ; inline
|
seq>> [ length ] keep zip ; inline
|
||||||
|
|
|
@ -211,7 +211,7 @@ ERROR: topological-sort-failed ;
|
||||||
: sort-classes ( seq -- newseq )
|
: sort-classes ( seq -- newseq )
|
||||||
[ name>> ] sort-with >vector
|
[ name>> ] sort-with >vector
|
||||||
[ dup empty? not ]
|
[ dup empty? not ]
|
||||||
[ dup largest-class [ over delete-nth ] dip ]
|
[ dup largest-class [ over remove-nth! drop ] dip ]
|
||||||
produce nip ;
|
produce nip ;
|
||||||
|
|
||||||
: smallest-class ( classes -- class/f )
|
: smallest-class ( classes -- class/f )
|
||||||
|
|
|
@ -503,8 +503,8 @@ HELP: delq
|
||||||
{ $notes "This word uses identity comparison (" { $link eq? } ")." }
|
{ $notes "This word uses identity comparison (" { $link eq? } ")." }
|
||||||
{ $side-effects "seq" } ;
|
{ $side-effects "seq" } ;
|
||||||
|
|
||||||
HELP: delete-nth
|
HELP: remove-nth!
|
||||||
{ $values { "n" "a non-negative integer" } { "seq" "a resizable mutable sequence" } }
|
{ $values { "n" "a non-negative integer" } { "seq" "a resizable mutable sequence" } { "seq" "a resizable mutable sequence" } }
|
||||||
{ $description "Removes the " { $snippet "n" } "th element from the sequence, shifting all other elements down and reducing its length by one." }
|
{ $description "Removes the " { $snippet "n" } "th element from the sequence, shifting all other elements down and reducing its length by one." }
|
||||||
{ $side-effects "seq" } ;
|
{ $side-effects "seq" } ;
|
||||||
|
|
||||||
|
@ -861,7 +861,7 @@ HELP: tail?
|
||||||
{ $values { "seq" sequence } { "end" sequence } { "?" "a boolean" } }
|
{ $values { "seq" sequence } { "end" sequence } { "?" "a boolean" } }
|
||||||
{ $description "Tests if " { $snippet "seq" } " ends with " { $snippet "end" } ". If " { $snippet "end" } " is longer than " { $snippet "seq" } ", this word outputs " { $link f } "." } ;
|
{ $description "Tests if " { $snippet "seq" } " ends with " { $snippet "end" } ". If " { $snippet "end" } " is longer than " { $snippet "seq" } ", this word outputs " { $link f } "." } ;
|
||||||
|
|
||||||
{ remove remove-nth remq delq remove! delete-nth } related-words
|
{ remove remove-nth remq delq remove! remove-nth! } related-words
|
||||||
|
|
||||||
HELP: cut-slice
|
HELP: cut-slice
|
||||||
{ $values { "seq" sequence } { "n" "a non-negative integer" } { "before-slice" sequence } { "after-slice" "a slice" } }
|
{ $values { "seq" sequence } { "n" "a non-negative integer" } { "before-slice" sequence } { "after-slice" "a slice" } }
|
||||||
|
@ -1595,7 +1595,7 @@ ARTICLE: "sequences-destructive" "Destructive operations"
|
||||||
{ $subsections
|
{ $subsections
|
||||||
remove!
|
remove!
|
||||||
delq
|
delq
|
||||||
delete-nth
|
remove-nth!
|
||||||
delete-slice
|
delete-slice
|
||||||
delete-all
|
delete-all
|
||||||
filter-here
|
filter-here
|
||||||
|
@ -1616,7 +1616,7 @@ ARTICLE: "sequences-destructive" "Destructive operations"
|
||||||
{ { $link unclip-last } { $link pop } }
|
{ { $link unclip-last } { $link pop } }
|
||||||
{ { $link remove } { $link remove! } }
|
{ { $link remove } { $link remove! } }
|
||||||
{ { $link remq } { $link delq } }
|
{ { $link remq } { $link delq } }
|
||||||
{ { $link remove-nth } { $link delete-nth } }
|
{ { $link remove-nth } { $link remove-nth! } }
|
||||||
{ { $link reverse } { $link reverse-here } }
|
{ { $link reverse } { $link reverse-here } }
|
||||||
{ { $link append } { $link push-all } }
|
{ { $link append } { $link push-all } }
|
||||||
{ { $link map } { $link map! } }
|
{ { $link map } { $link map! } }
|
||||||
|
|
|
@ -207,7 +207,7 @@ unit-test
|
||||||
[ 10 "hi" "bye" copy ] must-fail
|
[ 10 "hi" "bye" copy ] must-fail
|
||||||
|
|
||||||
[ V{ 1 2 3 5 6 } ] [
|
[ V{ 1 2 3 5 6 } ] [
|
||||||
3 V{ 1 2 3 4 5 6 } clone [ delete-nth ] keep
|
3 V{ 1 2 3 4 5 6 } clone remove-nth!
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
! erg's random tester found this one
|
! erg's random tester found this one
|
||||||
|
@ -227,7 +227,7 @@ unit-test
|
||||||
[ -3 10 nth ] must-fail
|
[ -3 10 nth ] must-fail
|
||||||
[ 11 10 nth ] must-fail
|
[ 11 10 nth ] must-fail
|
||||||
|
|
||||||
[ -1/0. 0 delete-nth ] must-fail
|
[ -1/0. 0 remove-nth! ] must-fail
|
||||||
[ "" ] [ "" [ CHAR: \s = ] trim ] unit-test
|
[ "" ] [ "" [ CHAR: \s = ] trim ] unit-test
|
||||||
[ "" ] [ "" [ CHAR: \s = ] trim-head ] unit-test
|
[ "" ] [ "" [ CHAR: \s = ] trim-head ] unit-test
|
||||||
[ "" ] [ "" [ CHAR: \s = ] trim-tail ] unit-test
|
[ "" ] [ "" [ CHAR: \s = ] trim-tail ] unit-test
|
||||||
|
|
|
@ -695,8 +695,8 @@ PRIVATE>
|
||||||
: delete-slice ( from to seq -- )
|
: delete-slice ( from to seq -- )
|
||||||
check-slice [ over [ - ] dip ] dip open-slice ;
|
check-slice [ over [ - ] dip ] dip open-slice ;
|
||||||
|
|
||||||
: delete-nth ( n seq -- )
|
: remove-nth! ( n seq -- seq )
|
||||||
[ dup 1 + ] dip delete-slice ;
|
[ [ dup 1 + ] dip delete-slice ] keep ;
|
||||||
|
|
||||||
: snip ( from to seq -- head tail )
|
: snip ( from to seq -- head tail )
|
||||||
[ swap head ] [ swap tail ] bi-curry bi* ; inline
|
[ swap head ] [ swap tail ] bi-curry bi* ; inline
|
||||||
|
|
|
@ -81,7 +81,7 @@ SYMBOL: total
|
||||||
|
|
||||||
: topological-sort ( seq quot -- newseq )
|
: topological-sort ( seq quot -- newseq )
|
||||||
[ >vector [ dup empty? not ] ] dip
|
[ >vector [ dup empty? not ] ] dip
|
||||||
[ dupd maximal-element [ over delete-nth ] dip ] curry
|
[ dupd maximal-element [ over remove-nth! drop ] dip ] curry
|
||||||
produce nip ; inline
|
produce nip ; inline
|
||||||
|
|
||||||
: classes< ( seq1 seq2 -- lt/eq/gt )
|
: classes< ( seq1 seq2 -- lt/eq/gt )
|
||||||
|
|
|
@ -53,7 +53,7 @@ syn keyword factorKeyword or tuck 2bi 2tri while wrapper nip 4dip wrapper? bi* c
|
||||||
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 <enum> assoc assoc-map enum value-at* remove-all 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 <enum> assoc assoc-map enum value-at* remove-all 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 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 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 <fp-nan> < 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 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 <fp-nan> < 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 remq but-last snip trim-tail nths nth 2pusher sequence slice? <slice> partition remove-nth tail-slice empty? tail* if-empty find-from virtual-sequence? member? set-length delq 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 delete-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 <flat-slice> second map! join when-empty accumulator immutable-sequence? <reversed> 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? <repetition> 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-here last-index-from reversed index-from cut* pad-tail (indices) concat-as remq but-last snip trim-tail nths nth 2pusher sequence slice? <slice> partition remove-nth tail-slice empty? tail* if-empty find-from virtual-sequence? member? set-length delq 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 <flat-slice> second map! join when-empty accumulator immutable-sequence? <reversed> 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? <repetition> 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 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 <array> 2array 3array pair >array 1array 4array pair? array resize-array array?
|
syn keyword factorKeyword <array> 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
|
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
|
||||||
|
|
Loading…
Reference in New Issue