Remove cache-nth word, nobody was using it and the semantics were broken
parent
ce269c8733
commit
d1744fd67a
|
@ -416,11 +416,6 @@ HELP: interleave
|
|||
{ $description "Applies " { $snippet "quot" } " to each element in turn, also invoking " { $snippet "between" } " in-between each pair of elements." }
|
||||
{ $example "USING: io sequences ;" "{ \"a\" \"b\" \"c\" } [ \"X\" write ] [ write ] interleave" "aXbXc" } ;
|
||||
|
||||
HELP: cache-nth
|
||||
{ $values { "i" "a non-negative integer" } { "seq" "a mutable sequence" } { "quot" { $quotation "( i -- elt )" } } { "elt" object } }
|
||||
{ $description "If the sequence does not contain at least " { $snippet "i" } " elements or if the " { $snippet "i" } "th element of the sequence is " { $link f } ", calls the quotation to produce a new value, and stores it back into the sequence. Otherwise, this word outputs the " { $snippet "i" } "th element of the sequence." }
|
||||
{ $side-effects "seq" } ;
|
||||
|
||||
HELP: index
|
||||
{ $values { "obj" object } { "seq" sequence } { "n" "an index" } }
|
||||
{ $description "Outputs the index of the first element in the sequence equal to " { $snippet "obj" } ". If no element is found, outputs " { $link f } "." } ;
|
||||
|
@ -1497,7 +1492,6 @@ ARTICLE: "sequences-destructive" "Destructive operations"
|
|||
"Changing elements:"
|
||||
{ $subsection change-each }
|
||||
{ $subsection change-nth }
|
||||
{ $subsection cache-nth }
|
||||
"Deleting elements:"
|
||||
{ $subsection delete }
|
||||
{ $subsection delq }
|
||||
|
|
|
@ -190,16 +190,6 @@ unit-test
|
|||
|
||||
[ V{ "a" "b" } V{ } ] [ { "X" "a" "b" } { "X" } drop-prefix [ >vector ] bi@ ] unit-test
|
||||
|
||||
[ 1 4 9 16 16 V{ f 1 4 9 16 } ] [
|
||||
V{ } clone "cache-test" set
|
||||
1 "cache-test" get [ sq ] cache-nth
|
||||
2 "cache-test" get [ sq ] cache-nth
|
||||
3 "cache-test" get [ sq ] cache-nth
|
||||
4 "cache-test" get [ sq ] cache-nth
|
||||
4 "cache-test" get [ "wrong" ] cache-nth
|
||||
"cache-test" get
|
||||
] unit-test
|
||||
|
||||
[ 1 ] [ 0.5 { 1 2 3 } nth ] unit-test
|
||||
|
||||
! Pathological case
|
||||
|
|
|
@ -523,13 +523,6 @@ PRIVATE>
|
|||
: harvest ( seq -- newseq )
|
||||
[ empty? not ] filter ;
|
||||
|
||||
: cache-nth ( i seq quot -- elt )
|
||||
2over ?nth dup [
|
||||
[ 3drop ] dip
|
||||
] [
|
||||
drop swap [ over [ call dup ] dip ] dip set-nth
|
||||
] if ; inline
|
||||
|
||||
: mismatch ( seq1 seq2 -- i )
|
||||
[ min-length ] 2keep
|
||||
[ 2nth-unsafe = not ] 2curry
|
||||
|
|
Loading…
Reference in New Issue