grouping: Remove <clumps> and <circular-clumps> and rename <sliced-clumps>

and <sliced-circular-clumps> to those. Fixes #765.
db4
Doug Coleman 2013-03-23 11:38:05 -07:00
parent 8917ae9ad7
commit 11af4e1781
5 changed files with 18 additions and 43 deletions

View 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." }

View 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

View 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
: <sliced-clumps> ( seq n -- clumps )
sliced-clumps new-groups ; inline
: map-like ( seq n quot -- seq )
2keep drop '[ _ like ] map ; inline
: group ( seq n -- array ) [ <groups> ] 2keep drop '[ _ like ] map ;
PRIVATE>
: clump ( seq n -- array ) <clumps> { } like ;
: group ( seq n -- array ) [ <groups> ] map-like ; inline
: 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

View 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

View 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 )