]> gitweb.factorcode.org Git - factor.git/commitdiff
grouping: The expectation is that if there is a virtual clump of length N, then each...
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 29 Oct 2012 16:47:15 +0000 (09:47 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 29 Oct 2012 16:47:15 +0000 (09:47 -0700)
Revert "change clump when the group size is greater than the sequence length"

This reverts commit baedb316c5e5c966400b903ac9bebd9bc70fbeba.

Conflicts:
basis/grouping/grouping-docs.factor
basis/grouping/grouping-tests.factor
basis/grouping/grouping.factor

basis/grouping/grouping-docs.factor
basis/grouping/grouping-tests.factor
basis/grouping/grouping.factor

index 64f277ee940d30d8db08af30ce494e5b7c94a6ed..6a02e2198e1c4caf0ba4b55a0216ac8624860067 100644 (file)
@@ -117,7 +117,7 @@ $nl
 HELP: clump
 { $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "array" "a sequence of sequences" } }
 { $description "Splits the sequence into overlapping clumps of " { $snippet "n" } " elements and collects the clumps into a new array." }
-{ $notes "For an empty sequence, the result is an empty sequence. For a non empty sequence with a length smaller than " { $snippet "n" } ", the result will be a sequence with one element: the input sequence " { $snippet "seq" } "." }
+{ $notes "For an empty sequence, the result is an empty sequence. For a non empty sequence with a length smaller than " { $snippet "n" } ", the result will be an empty sequence." }
 { $examples
     { $example "USING: grouping prettyprint ;" "{ 3 1 3 3 7 } 2 clump ." "{ { 3 1 } { 1 3 } { 3 3 } { 3 7 } }" }
 } ;
index 605b2b76ce12482fec5032de52fd0020fb95037d..6e207ceffa1c9a471e5dd4e1d8882c57a5070654 100644 (file)
@@ -13,11 +13,11 @@ IN: grouping.tests
 ] unit-test
 
 [ 0 ] [ { } 2 <clumps> length ] unit-test
-[ 1 ] [ { 1 } 2 <clumps> length ] unit-test
+[ 0 ] [ { 1 } 2 <clumps> length ] unit-test
 [ 1 ] [ { 1 2 } 2 <clumps> length ] unit-test
 [ 2 ] [ { 1 2 3 } 2 <clumps> length ] unit-test
 
-{ { { 1 } } } [ { 1 } 2 clump ] unit-test
+{ { } } [ { 1 } 2 clump ] unit-test
 { { { 1 2 } } } [ { 1 2 } 2 clump ] unit-test
 { { { 1 2 } { 2 3 } } } [ { 1 2 3 } 2 clump ] unit-test
 
index c7733b871d4fc171d0bce7fbe92c7a713c1d8b6b..99cefa3cf0df94f6f6b9f3f956a581cda457754f 100644 (file)
@@ -45,14 +45,14 @@ INSTANCE: abstract-clumps sequence
 
 M: abstract-clumps length
     dup seq>> length [ drop 0 ] [
-        swap [ 1 + ] [ n>> ] bi* - 1 max
+        swap [ 1 + ] [ n>> ] bi* [-]
     ] if-zero ; inline
 
 M: abstract-clumps set-length
     [ n>> + 1 - ] [ seq>> ] bi set-length ; inline
 
 M: abstract-clumps group@
-    [ [ n>> over + ] [ seq>> length ] bi min ] [ seq>> ] bi ; inline
+    [ n>> over + ] [ seq>> ] bi ; inline
 
 TUPLE: chunking-seq { seq read-only } { n read-only } ;