]> gitweb.factorcode.org Git - factor.git/commitdiff
grouping: Remove <clumps> and <circular-clumps> and rename <sliced-clumps>
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 23 Mar 2013 18:38:05 +0000 (11:38 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 23 Mar 2013 18:38:05 +0000 (11:38 -0700)
and <sliced-circular-clumps> to those. Fixes #765.

basis/grouping/grouping-docs.factor
basis/grouping/grouping-tests.factor
basis/grouping/grouping.factor
extra/grid-meshes/grid-meshes.factor
extra/sequences/extras/extras.factor

index 571555e4e1be0fea26ddec2138992a7aef5e7c49..ff8a3f6ac4bbfc3804afbc5ec8559a3862d441db 100644 (file)
@@ -11,9 +11,9 @@ ARTICLE: "grouping" "Groups and clumps"
 "Splitting a sequence into overlapping, fixed-length subsequences, wrapping around the end of the sequence:"
 { $subsections circular-clump }
 "A virtual sequence for splitting a sequence into overlapping, fixed-length subsequences:"
-{ $subsections clumps <clumps> <sliced-clumps> }
+{ $subsections clumps <clumps> }
 "A virtual sequence for splitting a sequence into overlapping, fixed-length subsequences:"
-{ $subsections circular-clumps <circular-clumps> <sliced-circular-clumps> }
+{ $subsections circular-clumps <circular-clumps> }
 "The difference can be summarized as the following:"
 { $list
     { "With groups, the subsequences form the original sequence when concatenated:"
@@ -97,7 +97,7 @@ $nl
 HELP: circular-clumps
 { $class-description "Instances are virtual sequences whose elements are overlapping fixed-length subsequences of an underlying sequence, beginning with every element in the original sequence and wrapping around its end. Circular clumps are mutable and resizable if the underlying sequence is mutable and resizable, respectively."
 $nl
-"New clumps are created by calling " { $link <circular-clumps> } " and " { $link <sliced-circular-clumps> } "." } ;
+"New clumps are created by calling " { $link <circular-clumps> } "." } ;
 
 HELP: clump
 { $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "array" "a sequence of sequences" } }
@@ -137,7 +137,7 @@ HELP: <clumps>
 
 HELP: <circular-clumps>
 { $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "clumps" clumps } }
-{ $description "Outputs a virtual sequence whose elements are overlapping subsequences of " { $snippet "n" } " elements from the underlying sequence, starting with each of its elements and wrapping around the end of the sequence." }
+{ $description "Outputs a virtual sequence whose elements are overlapping slices of " { $snippet "n" } " elements from the underlying sequence, starting with each of its elements and wrapping around the end of the sequence." }
 { $examples
     { $example
         "USING: kernel sequences grouping prettyprint ;"
@@ -146,25 +146,12 @@ HELP: <circular-clumps>
     }
 } ;
 
-HELP: <sliced-circular-clumps>
-{ $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "clumps" clumps } }
-{ $description "Outputs a virtual sequence whose elements are overlapping slices of " { $snippet "n" } " elements from the underlying sequence, starting with each of its elements and wrapping around the end of the sequence." }
-{ $examples
-    { $example
-        "USING: arrays kernel sequences grouping prettyprint ;"
-        "{ 1 2 3 4 } 3 <sliced-circular-clumps> third >array ."
-        "{ 3 4 1 }"
-    }
-} ;
-
 { clumps circular-clumps groups } related-words
 
 { clump circular-clump group } related-words
 
 { <clumps> <circular-clumps> <groups> } related-words
 
-{ <sliced-clumps> <sliced-circular-clumps> <groups> } related-words
-
 HELP: monotonic?
 { $values { "seq" sequence } { "quot" { $quotation "( elt1 elt2 -- ? )" } } { "?" "a boolean" } }
 { $description "Applies the relation to successive pairs of elements in the sequence, testing for a truth value. The relation should be a transitive relation, such as a total order or an equality relation." }
index c90488ff29198ff76e88e39a036923169f9656a3..a6e30d9d61588b2d378ed6657f8e21ca3fa12271 100644 (file)
@@ -29,7 +29,7 @@ IN: grouping.tests
 [ 2 ] [ V{ } 2 <clumps> 1 over set-length seq>> length ] unit-test
 [ 3 ] [ V{ } 2 <clumps> 2 over set-length seq>> length ] unit-test
 
-[ { { 1 2 } { 2 3 } } ] [ { 1 2 3 } 2 <sliced-clumps> [ >array ] map ] unit-test
+[ { { 1 2 } { 2 3 } } ] [ { 1 2 3 } 2 <clumps> [ >array ] map ] unit-test
 
 [ f ] [ [ { } { } "Hello" ] all-equal? ] unit-test
 [ f ] [ [ { 2 } { } { } ] all-equal? ] unit-test
index 0e604d5812009c763623ec23f8c1c656addb1945..eb9fd54666b8d15379010d5f8a706a0f281e7c3a 100644 (file)
@@ -72,22 +72,22 @@ INSTANCE: groups abstract-groups
     groups new-groups ; inline
 
 TUPLE: clumps < chunking-seq ;
-INSTANCE: clumps subseq-chunking
+INSTANCE: clumps slice-chunking
 INSTANCE: clumps abstract-clumps
 
 : <clumps> ( seq n -- clumps )
     clumps new-groups ; inline
 
-TUPLE: sliced-clumps < chunking-seq ;
-INSTANCE: sliced-clumps slice-chunking
-INSTANCE: sliced-clumps abstract-clumps
+<PRIVATE
+
+: map-like ( seq n quot -- seq )
+    2keep drop '[ _ like ] map ; inline
 
-: <sliced-clumps> ( seq n -- clumps )
-    sliced-clumps new-groups ; inline
+PRIVATE>
 
-: group ( seq n -- array ) [ <groups> ] 2keep drop '[ _ like ] map ;
+: group ( seq n -- array ) [ <groups> ] map-like ; inline
 
-: clump ( seq n -- array ) <clumps> { } like ;
+: clump ( seq n -- array ) [ <clumps> ] map-like ; inline
 
 : monotonic? ( seq quot: ( elt1 elt2 -- ? ) -- ? )
     over length dup 2 < [ 3drop t ] [
@@ -120,18 +120,6 @@ M: circular-slice virtual@
 
 C: <circular-slice> circular-slice
 
-TUPLE: sliced-circular-clumps < chunking-seq ;
-INSTANCE: sliced-circular-clumps sequence
-
-M: sliced-circular-clumps length
-    seq>> length ; inline
-
-M: sliced-circular-clumps nth
-    [ n>> over + ] [ seq>> ] bi <circular-slice> ; inline
-
-: <sliced-circular-clumps> ( seq n -- clumps )
-    sliced-circular-clumps new-groups ; inline
-
 TUPLE: circular-clumps < chunking-seq ;
 INSTANCE: circular-clumps sequence
 
@@ -139,10 +127,10 @@ M: circular-clumps length
     seq>> length ; inline
 
 M: circular-clumps nth
-    [ n>> over + ] [ seq>> ] bi [ <circular-slice> ] [ like ] bi ; inline
+    [ n>> over + ] [ seq>> ] bi <circular-slice> ; inline
 
 : <circular-clumps> ( seq n -- clumps )
     circular-clumps new-groups ; inline
 
 : circular-clump ( seq n -- array )
-    <circular-clumps> { } like ; inline
+    [ <circular-clumps> ] map-like ; inline
\ No newline at end of file
index 47f649868ea4ec3ef7d5c0b6d99d6a720fda71c6..092a3e35d19ce2159de76f5d3d9e1903b3baa25f 100644 (file)
@@ -16,7 +16,7 @@ TUPLE: grid-mesh dim buffer row-length ;
 
 : vertex-array ( dim -- vertices )
     first2 [ [ 0.0 1.0 1.0 ] dip /f <range> ] bi@
-    2 <sliced-clumps> [ first2 vertex-array-row ] with map concat ;
+    2 <clumps> [ first2 vertex-array-row ] with map concat ;
 
 : >vertex-buffer ( bytes -- buffer )
     [ GL_ARRAY_BUFFER ] dip GL_STATIC_DRAW <gl-buffer> ; inline
index 87704d7d55f819bfd0a28a2bfa1fee11ca1e4c8d..60d8b438636ed089bef6c03d4fb7ece2fcaac6cf 100644 (file)
@@ -32,7 +32,7 @@ IN: sequences.extras
     [ swap ] 2dip each-from ; inline
 
 : all-subseqs ( seq -- seqs )
-    dup length [1,b] [ <clumps> ] with map concat ;
+    dup length [1,b] [ clump ] with map concat ;
 
 :: each-subseq ( ... seq quot: ( ... x -- ... ) -- ... )
     seq length :> len
@@ -49,7 +49,7 @@ IN: sequences.extras
 
 : filter-all-subseqs-range ( ... seq range quot: ( ... x -- ... ) -- seq )
     [
-        '[ <sliced-clumps> _ filter ] with map concat
+        '[ <clumps> _ filter ] with map concat
     ] 3keep 2drop map-like ; inline
 
 : filter-all-subseqs ( ... seq quot: ( ... x -- ... ) -- seq )