]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences: remove stupid <flat-slice> word
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 17 Apr 2010 05:58:30 +0000 (00:58 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 17 Apr 2010 05:58:30 +0000 (00:58 -0500)
basis/compiler/tests/optimizer.factor
core/sequences/sequences-docs.factor
core/sequences/sequences.factor

index 2e305b2c39e99119364676c796dea8446fd11160..13917fd6bfd1be3cdf8fd8926bac9c41239f57a1 100644 (file)
@@ -193,25 +193,6 @@ M: number detect-number ;
 ! Regression
 [ 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
 : empty-compound ( -- ) ;
 
index f7f774ad8615bc2f399884327be46e732beb4466..e6c656f2da2dde6670798fbd0abc1e46d446c448 100644 (file)
@@ -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." }
 ;
 
-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>
 { $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" } "." }
 { $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
 
@@ -1534,8 +1529,6 @@ $nl
 { $subsections rest-slice but-last-slice }
 "Taking a sequence apart into a head and a tail:"
 { $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:"
 { $subsections replace-slice } ;
 
index d9c234e717981842d1b565da99d2c1acc5e67af3..2155f1439fd009fb20d501fdc90b6b23216d5e5b 100644 (file)
@@ -898,11 +898,6 @@ PRIVATE>
 : unclip-last-slice ( seq -- butlast-slice last )
     [ but-last-slice ] [ last ] bi ; inline
 
-: <flat-slice> ( seq -- slice )
-    dup slice? [ { } like ] when
-    [ drop 0 ] [ length ] [ ] tri <slice> ;
-    inline
-
 <PRIVATE
     
 : (trim-head) ( seq quot -- seq n )