sequences: remove stupid <flat-slice> word
parent
8d3d425d44
commit
c1a870fe72
|
@ -193,25 +193,6 @@ M: number detect-number ;
|
||||||
! Regression
|
! Regression
|
||||||
[ 4 [ + ] ] [ 2 2 [ [ + ] [ call ] keep ] compile-call ] unit-test
|
[ 4 [ + ] ] [ 2 2 [ [ + ] [ call ] keep ] compile-call ] unit-test
|
||||||
|
|
||||||
! Regression
|
|
||||||
USE: sorting
|
|
||||||
USE: binary-search
|
|
||||||
USE: binary-search.private
|
|
||||||
|
|
||||||
: old-binsearch ( elt quot: ( ..a -- ..b ) seq -- elt quot i )
|
|
||||||
dup length 1 <= [
|
|
||||||
from>>
|
|
||||||
] [
|
|
||||||
[ midpoint swap call ] 3keep [ rot ] dip swap dup zero?
|
|
||||||
[ drop dup from>> swap midpoint@ + ]
|
|
||||||
[ drop dup midpoint@ head-slice old-binsearch ] if
|
|
||||||
] if ; inline recursive
|
|
||||||
|
|
||||||
[ 10 ] [
|
|
||||||
10 20 iota <flat-slice>
|
|
||||||
[ [ - ] swap old-binsearch ] compile-call 2nip
|
|
||||||
] unit-test
|
|
||||||
|
|
||||||
! Regression
|
! Regression
|
||||||
: empty-compound ( -- ) ;
|
: empty-compound ( -- ) ;
|
||||||
|
|
||||||
|
|
|
@ -679,16 +679,11 @@ HELP: collapse-slice
|
||||||
{ $description "Prepares to take the slice of a slice by adjusting the start and end indices accordingly, and replacing the slice with its underlying sequence." }
|
{ $description "Prepares to take the slice of a slice by adjusting the start and end indices accordingly, and replacing the slice with its underlying sequence." }
|
||||||
;
|
;
|
||||||
|
|
||||||
HELP: <flat-slice>
|
|
||||||
{ $values { "seq" sequence } { "slice" slice } }
|
|
||||||
{ $description "Outputs a slice with the same elements as " { $snippet "seq" } ", and " { $snippet "from" } " equal to 0 and " { $snippet "to" } " equal to the length of " { $snippet "seq" } "." }
|
|
||||||
{ $notes "Some words create slices then proceed to read the " { $snippet "to" } " and " { $snippet "from" } " slots of the slice. To behave predictably when they are themselves given a slice as input, they apply this word first to get a canonical slice." } ;
|
|
||||||
|
|
||||||
HELP: <slice>
|
HELP: <slice>
|
||||||
{ $values { "from" "a non-negative integer" } { "to" "a non-negative integer" } { "seq" sequence } { "slice" slice } }
|
{ $values { "from" "a non-negative integer" } { "to" "a non-negative integer" } { "seq" sequence } { "slice" slice } }
|
||||||
{ $description "Outputs a new virtual sequence sharing storage with the subrange of elements in " { $snippet "seq" } " with indices starting from and including " { $snippet "m" } ", and up to but not including " { $snippet "n" } "." }
|
{ $description "Outputs a new virtual sequence sharing storage with the subrange of elements in " { $snippet "seq" } " with indices starting from and including " { $snippet "m" } ", and up to but not including " { $snippet "n" } "." }
|
||||||
{ $errors "Throws an error if " { $snippet "m" } " or " { $snippet "n" } " is out of bounds." }
|
{ $errors "Throws an error if " { $snippet "m" } " or " { $snippet "n" } " is out of bounds." }
|
||||||
{ $notes "Taking the slice of a slice outputs a slice of the underlying sequence of the original slice. Keep this in mind when writing code which depends on the values of " { $snippet "from" } " and " { $snippet "to" } " being equal to the inputs to this word. The " { $link <flat-slice> } " word might be helpful in such situations." } ;
|
{ $notes "Taking the slice of a slice outputs a slice of the underlying sequence, instead of a slice of a slice. This means that you cannot assume that the " { $snippet "from" } " and " { $snippet "to" } " slots of the resulting slice will be equal to the values you passed to " { $link <slice> } "." } ;
|
||||||
|
|
||||||
{ <slice> subseq } related-words
|
{ <slice> subseq } related-words
|
||||||
|
|
||||||
|
@ -1534,8 +1529,6 @@ $nl
|
||||||
{ $subsections rest-slice but-last-slice }
|
{ $subsections rest-slice but-last-slice }
|
||||||
"Taking a sequence apart into a head and a tail:"
|
"Taking a sequence apart into a head and a tail:"
|
||||||
{ $subsections unclip-slice unclip-last-slice cut-slice }
|
{ $subsections unclip-slice unclip-last-slice cut-slice }
|
||||||
"A utility for words which use slices as iterators:"
|
|
||||||
{ $subsections <flat-slice> }
|
|
||||||
"Replacing slices with new elements:"
|
"Replacing slices with new elements:"
|
||||||
{ $subsections replace-slice } ;
|
{ $subsections replace-slice } ;
|
||||||
|
|
||||||
|
|
|
@ -898,11 +898,6 @@ PRIVATE>
|
||||||
: unclip-last-slice ( seq -- butlast-slice last )
|
: unclip-last-slice ( seq -- butlast-slice last )
|
||||||
[ but-last-slice ] [ last ] bi ; inline
|
[ but-last-slice ] [ last ] bi ; inline
|
||||||
|
|
||||||
: <flat-slice> ( seq -- slice )
|
|
||||||
dup slice? [ { } like ] when
|
|
||||||
[ drop 0 ] [ length ] [ ] tri <slice> ;
|
|
||||||
inline
|
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: (trim-head) ( seq quot -- seq n )
|
: (trim-head) ( seq quot -- seq n )
|
||||||
|
|
Loading…
Reference in New Issue