grouping: Remove <groups>, old <sliced-groups> is now <groups>. Fixes

db4
Doug Coleman 2013-03-23 11:11:40 -07:00
parent 02156a0c0c
commit 8917ae9ad7
7 changed files with 15 additions and 45 deletions

View File

@ -90,7 +90,7 @@ generic-call-site-crossref [ H{ } clone ] initialize
get remove-vertex* ; get remove-vertex* ;
: generic-call-sites ( word -- alist ) : generic-call-sites ( word -- alist )
"generic-call-sites" word-prop 2 <groups> ; "generic-call-sites" word-prop 2 group ;
: compiled-unxref ( word -- ) : compiled-unxref ( word -- )
{ {

View File

@ -5,7 +5,7 @@ ARTICLE: "grouping" "Groups and clumps"
"Splitting a sequence into disjoint, fixed-length subsequences:" "Splitting a sequence into disjoint, fixed-length subsequences:"
{ $subsections group } { $subsections group }
"A virtual sequence for splitting a sequence into disjoint, fixed-length subsequences:" "A virtual sequence for splitting a sequence into disjoint, fixed-length subsequences:"
{ $subsections groups <groups> <sliced-groups> } { $subsections groups <groups> }
"Splitting a sequence into overlapping, fixed-length subsequences:" "Splitting a sequence into overlapping, fixed-length subsequences:"
{ $subsections clump } { $subsections clump }
"Splitting a sequence into overlapping, fixed-length subsequences, wrapping around the end of the sequence:" "Splitting a sequence into overlapping, fixed-length subsequences, wrapping around the end of the sequence:"
@ -62,7 +62,7 @@ ABOUT: "grouping"
HELP: groups HELP: groups
{ $class-description "Instances are virtual sequences whose elements are disjoint fixed-length subsequences of an underlying sequence. Groups are mutable and resizable if the underlying sequence is mutable and resizable, respectively." { $class-description "Instances are virtual sequences whose elements are disjoint fixed-length subsequences of an underlying sequence. Groups are mutable and resizable if the underlying sequence is mutable and resizable, respectively."
$nl $nl
"New groups are created by calling " { $link <groups> } " and " { $link <sliced-groups> } "." } ; "New groups are created by calling " { $link <groups> } "." } ;
HELP: group HELP: group
{ $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "array" "a sequence of sequences" } } { $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "array" "a sequence of sequences" } }
@ -74,32 +74,17 @@ HELP: group
HELP: <groups> HELP: <groups>
{ $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "groups" groups } } { $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "groups" groups } }
{ $description "Outputs a virtual sequence whose elements are disjoint subsequences of " { $snippet "n" } " elements from the underlying sequence." }
{ $examples
{ $example
"USING: arrays kernel prettyprint sequences grouping ;"
"9 iota >array 3 <groups> reverse! concat >array ." "{ 6 7 8 3 4 5 0 1 2 }"
}
{ $example
"USING: kernel prettyprint sequences grouping ;"
"{ 1 2 3 4 5 6 } 3 <groups> first ."
"{ 1 2 3 }"
}
} ;
HELP: <sliced-groups>
{ $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "groups" groups } }
{ $description "Outputs a virtual sequence whose elements are slices of disjoint subsequences of " { $snippet "n" } " elements from the underlying sequence." } { $description "Outputs a virtual sequence whose elements are slices of disjoint subsequences of " { $snippet "n" } " elements from the underlying sequence." }
{ $examples { $examples
{ $example { $example
"USING: arrays kernel prettyprint sequences grouping ;" "USING: arrays kernel prettyprint sequences grouping ;"
"9 iota >array 3 <sliced-groups>" "9 iota >array 3 <groups>"
"dup [ reverse! drop ] each concat >array ." "dup [ reverse! drop ] each concat >array ."
"{ 2 1 0 5 4 3 8 7 6 }" "{ 2 1 0 5 4 3 8 7 6 }"
} }
{ $example { $example
"USING: kernel prettyprint sequences grouping ;" "USING: kernel prettyprint sequences grouping ;"
"{ 1 2 3 4 5 6 } 3 <sliced-groups> second ." "{ 1 2 3 4 5 6 } 3 <groups> second ."
"T{ slice { from 3 } { to 6 } { seq { 1 2 3 4 5 6 } } }" "T{ slice { from 3 } { to 6 } { seq { 1 2 3 4 5 6 } } }"
} }
} ; } ;
@ -107,7 +92,7 @@ HELP: <sliced-groups>
HELP: clumps HELP: clumps
{ $class-description "Instances are virtual sequences whose elements are overlapping fixed-length subsequences of an underlying sequence. Clumps are mutable and resizable if the underlying sequence is mutable and resizable, respectively." { $class-description "Instances are virtual sequences whose elements are overlapping fixed-length subsequences of an underlying sequence. Clumps are mutable and resizable if the underlying sequence is mutable and resizable, respectively."
$nl $nl
"New clumps are created by calling " { $link <clumps> } " and " { $link <sliced-clumps> } "." } ; "New clumps are created by calling " { $link <clumps> } " and " { $link <clumps> } "." } ;
HELP: circular-clumps 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." { $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."
@ -178,7 +163,7 @@ HELP: <sliced-circular-clumps>
{ <clumps> <circular-clumps> <groups> } related-words { <clumps> <circular-clumps> <groups> } related-words
{ <sliced-clumps> <sliced-circular-clumps> <sliced-groups> } related-words { <sliced-clumps> <sliced-circular-clumps> <groups> } related-words
HELP: monotonic? HELP: monotonic?
{ $values { "seq" sequence } { "quot" { $quotation "( elt1 elt2 -- ? )" } } { "?" "a boolean" } } { $values { "seq" sequence } { "quot" { $quotation "( elt1 elt2 -- ? )" } } { "?" "a boolean" } }

View File

@ -6,12 +6,6 @@ IN: grouping.tests
[ { "hell" "o wo" "rld" } ] [ "hello world" 4 group ] unit-test [ { "hell" "o wo" "rld" } ] [ "hello world" 4 group ] unit-test
[ { V{ "a" "b" } V{ 0 0 } } ] [
V{ "a" "b" } clone 2 <groups>
2 over set-length
>array
] unit-test
[ 0 ] [ { } 2 <clumps> length ] unit-test [ 0 ] [ { } 2 <clumps> length ] unit-test
[ 0 ] [ { 1 } 2 <clumps> length ] unit-test [ 0 ] [ { 1 } 2 <clumps> length ] unit-test
[ 1 ] [ { 1 2 } 2 <clumps> length ] unit-test [ 1 ] [ { 1 2 } 2 <clumps> length ] unit-test
@ -44,5 +38,3 @@ IN: grouping.tests
[ f ] [ [ 1.0 1 1 ] all-equal? ] unit-test [ f ] [ [ 1.0 1 1 ] all-equal? ] unit-test
[ t ] [ { 1 2 3 4 } [ < ] monotonic? ] unit-test [ t ] [ { 1 2 3 4 } [ < ] monotonic? ] unit-test
[ f ] [ { 1 2 3 4 } [ > ] monotonic? ] unit-test [ f ] [ { 1 2 3 4 } [ > ] monotonic? ] unit-test
[ { 6 7 8 3 4 5 0 1 2 } ] [ 9 iota >array dup 3 <groups> reverse! drop ] unit-test

View File

@ -65,19 +65,12 @@ TUPLE: chunking-seq { seq read-only } { n read-only } ;
PRIVATE> PRIVATE>
TUPLE: groups < chunking-seq ; TUPLE: groups < chunking-seq ;
INSTANCE: groups subseq-chunking INSTANCE: groups slice-chunking
INSTANCE: groups abstract-groups INSTANCE: groups abstract-groups
: <groups> ( seq n -- groups ) : <groups> ( seq n -- groups )
groups new-groups ; inline groups new-groups ; inline
TUPLE: sliced-groups < chunking-seq ;
INSTANCE: sliced-groups slice-chunking
INSTANCE: sliced-groups abstract-groups
: <sliced-groups> ( seq n -- groups )
sliced-groups new-groups ; inline
TUPLE: clumps < chunking-seq ; TUPLE: clumps < chunking-seq ;
INSTANCE: clumps subseq-chunking INSTANCE: clumps subseq-chunking
INSTANCE: clumps abstract-clumps INSTANCE: clumps abstract-clumps
@ -92,7 +85,7 @@ INSTANCE: sliced-clumps abstract-clumps
: <sliced-clumps> ( seq n -- clumps ) : <sliced-clumps> ( seq n -- clumps )
sliced-clumps new-groups ; inline sliced-clumps new-groups ; inline
: group ( seq n -- array ) <groups> { } like ; : group ( seq n -- array ) [ <groups> ] 2keep drop '[ _ like ] map ;
: clump ( seq n -- array ) <clumps> { } like ; : clump ( seq n -- array ) <clumps> { } like ;

View File

@ -5,13 +5,13 @@ images math.vectors arrays ;
IN: images.tessellation IN: images.tessellation
: group-rows ( bitmap bitmap-dim -- rows ) : group-rows ( bitmap bitmap-dim -- rows )
first <sliced-groups> ; inline first <groups> ; inline
: tesselate-rows ( bitmap-rows tess-dim -- bitmaps ) : tesselate-rows ( bitmap-rows tess-dim -- bitmaps )
second <sliced-groups> ; inline second <groups> ; inline
: tesselate-columns ( bitmap-rows tess-dim -- bitmaps ) : tesselate-columns ( bitmap-rows tess-dim -- bitmaps )
first '[ _ <sliced-groups> ] map flip ; inline first '[ _ <groups> ] map flip ; inline
: tesselate-bitmap ( bitmap bitmap-dim tess-dim -- bitmap-grid ) : tesselate-bitmap ( bitmap bitmap-dim tess-dim -- bitmap-grid )
[ group-rows ] dip [ group-rows ] dip

View File

@ -126,7 +126,7 @@ M: output-port stream-write1
: write-in-groups ( byte-array port -- ) : write-in-groups ( byte-array port -- )
[ binary-object uchar <c-direct-array> ] dip [ binary-object uchar <c-direct-array> ] dip
[ buffer>> size>> <sliced-groups> ] [ '[ _ stream-write ] ] bi [ buffer>> size>> <groups> ] [ '[ _ stream-write ] ] bi
each ; each ;
M: output-port stream-write M: output-port stream-write

View File

@ -204,7 +204,7 @@ TUPLE: code-block
{ size read-only } { size read-only }
{ entry-point read-only } ; { entry-point read-only } ;
TUPLE: code-blocks { blocks sliced-groups } { cache hashtable } ; TUPLE: code-blocks { blocks groups } { cache hashtable } ;
<PRIVATE <PRIVATE
@ -222,7 +222,7 @@ TUPLE: code-blocks { blocks sliced-groups } { cache hashtable } ;
} spread code-block boa ; inline } spread code-block boa ; inline
: <code-blocks> ( seq -- code-blocks ) : <code-blocks> ( seq -- code-blocks )
6 <sliced-groups> H{ } clone \ code-blocks boa ; 6 <groups> H{ } clone \ code-blocks boa ;
SYMBOL: code-heap-start SYMBOL: code-heap-start
SYMBOL: code-heap-end SYMBOL: code-heap-end