]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/grouping/grouping-docs.factor
grouping-docs: remove a duplicate link
[factor.git] / basis / grouping / grouping-docs.factor
index ff8a3f6ac4bbfc3804afbc5ec8559a3862d441db..4dedba2032b8be2d32dff868c1d42b59825e8ed1 100644 (file)
@@ -1,4 +1,4 @@
-USING: help.markup help.syntax sequences strings ;
+USING: help.markup help.syntax kernel sequences strings ;
 IN: grouping
 
 ARTICLE: "grouping" "Groups and clumps"
@@ -12,42 +12,53 @@ ARTICLE: "grouping" "Groups and clumps"
 { $subsections circular-clump }
 "A virtual sequence for splitting a sequence into overlapping, fixed-length subsequences:"
 { $subsections clumps <clumps> }
-"A virtual sequence for splitting a sequence into overlapping, fixed-length subsequences:"
+"A virtual sequence for splitting a sequence into overlapping, fixed-length subsequences, wrapping around the end of the sequence:"
 { $subsections circular-clumps <circular-clumps> }
 "The difference can be summarized as the following:"
 { $list
     { "With groups, the subsequences form the original sequence when concatenated:"
-        { $unchecked-example
-            "USING: grouping ;"
-            "{ 1 2 3 4 } 2 group ." "{ { 1 2 } { 3 4 } }"
+        { $example
+            "USING: grouping prettyprint ;"
+            "{ 1 2 3 4 } 2 group ."
+            "{ { 1 2 } { 3 4 } }"
         }
-        { $unchecked-example
+        { $example
             "USING: grouping ;"
-            "{ 1 2 3 4 } dup" "2 <groups> concat sequence= ." "t"
+            "{ 1 2 3 4 } dup"
+            "2 <groups> concat sequence= ."
+            "t"
         }
     }
     { "With clumps, collecting the first element of each subsequence but the last one, together with the last subsequence, yields the original sequence:"
-        { $unchecked-example
+        { $example
             "USING: grouping ;"
-            "{ 1 2 3 4 } 2 clump ." "{ { 1 2 } { 2 3 } { 3 4 } }"
+            "{ 1 2 3 4 } 2 clump ."
+            "{ { 1 2 } { 2 3 } { 3 4 } }"
         }
-        { $unchecked-example
+        { $example
             "USING: grouping assocs sequences ;"
-            "{ 1 2 3 4 } dup" "2 <clumps> unclip-last [ keys ] dip append sequence= ." "t"
+            "{ 1 2 3 4 } dup"
+            "2 <clumps> unclip-last [ keys ] dip append sequence= ."
+            "t"
         }
     }
     { "With circular clumps, collecting the first element of each subsequence yields the original sequence. Collecting the " { $snippet "n" } "th element of each subsequence would rotate the original sequence " { $snippet "n" } " elements rightward:"
-        { $unchecked-example
+        { $example
             "USING: grouping ;"
-            "{ 1 2 3 4 } 2 circular-clump ." "{ { 1 2 } { 2 3 } { 3 4 } { 4 1 } }"
+            "{ 1 2 3 4 } 2 circular-clump ."
+            "{ { 1 2 } { 2 3 } { 3 4 } { 4 1 } }"
         }
-        { $unchecked-example
+        { $example
             "USING: grouping assocs sequences ;"
-            "{ 1 2 3 4 } dup" "2 <circular-clumps> keys sequence= ." "t"
+            "{ 1 2 3 4 } dup"
+            "2 <circular-clumps> keys sequence= ."
+            "t"
         }
-        { $unchecked-example
+        { $example
             "USING: grouping ;"
-            "{ 1 2 3 4 } dup" "2 <circular-clumps> [ second ] { } map-as ." "{ 2 3 4 1 }"
+            "{ 1 2 3 4 }"
+            "2 <circular-clumps> [ second ] { } map-as ."
+            "{ 2 3 4 1 }"
         }
     }
 }
@@ -65,7 +76,7 @@ $nl
 "New groups are created by calling " { $link <groups> } "." } ;
 
 HELP: group
-{ $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "array" "a sequence of sequences" } }
+{ $values { "seq" sequence } { "n" "a non-negative integer" } { "array" "a sequence of sequences" } }
 { $description "Splits the sequence into disjoint groups of " { $snippet "n" } " elements and collects the groups into a new array." }
 { $notes "If the sequence length is not a multiple of " { $snippet "n" } ", the final subsequence in the list will be shorter than " { $snippet "n" } " elements." }
 { $examples
@@ -73,12 +84,12 @@ HELP: group
 } ;
 
 HELP: <groups>
-{ $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "groups" groups } }
+{ $values { "seq" 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." }
 { $examples
     { $example
         "USING: arrays kernel prettyprint sequences grouping ;"
-        "9 iota >array 3 <groups>"
+        "9 <iota> >array 3 <groups>"
         "dup [ reverse! drop ] each concat >array ."
         "{ 2 1 0 5 4 3 8 7 6 }"
     }
@@ -92,7 +103,7 @@ HELP: <groups>
 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."
 $nl
-"New clumps are created by calling " { $link <clumps> } " and " { $link <clumps> } "." } ;
+"New clumps are created by calling " { $link <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."
@@ -100,7 +111,7 @@ $nl
 "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" } }
+{ $values { "seq" 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 an empty sequence." }
 { $examples
@@ -108,15 +119,17 @@ HELP: clump
 } ;
 
 HELP: circular-clump
-{ $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "array" "a sequence of sequences" } }
+{ $values { "seq" sequence } { "n" "a non-negative integer" } { "array" "a sequence of sequences" } }
 { $description "Splits the sequence into overlapping clumps of " { $snippet "n" } " elements, wrapping around the end of the sequence, and collects the clumps into a new array." }
 { $notes "For an empty sequence, the result is an empty sequence." }
 { $examples
-    { $example "USING: grouping prettyprint ;" "{ 3 1 3 3 7 } 2 circular-clump ." "{ { 3 1 } { 1 3 } { 3 3 } { 3 7 } { 7 3 } }" }
+    { $example "USING: grouping prettyprint ;"
+    "{ 3 1 3 3 7 } 2 circular-clump ."
+    "{ { 3 1 } { 1 3 } { 3 3 } { 3 7 } { 7 3 } }" }
 } ;
 
 HELP: <clumps>
-{ $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "clumps" clumps } }
+{ $values { "seq" 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." }
 { $examples
     "Running averages:"
@@ -129,19 +142,19 @@ HELP: <clumps>
         "{ 113/400 167/400 201/400 241/400 243/400 91/200 1/4 }"
     }
     { $example
-        "USING: kernel sequences grouping prettyprint ;"
-        "{ 1 2 3 4 5 6 } 3 <clumps> second ."
+        "USING: arrays kernel sequences grouping prettyprint ;"
+        "{ 1 2 3 4 5 6 } 3 <clumps> second >array ."
         "{ 2 3 4 }"
     }
 } ;
 
 HELP: <circular-clumps>
-{ $values { "seq" "a sequence" } { "n" "a non-negative integer" } { "clumps" clumps } }
+{ $values { "seq" 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: kernel sequences grouping prettyprint ;"
-        "{ 1 2 3 4 } 3 <circular-clumps> third ."
+        "USING: arrays kernel sequences grouping prettyprint ;"
+        "{ 1 2 3 4 } 3 <circular-clumps> third >array ."
         "{ 3 4 1 }"
     }
 } ;
@@ -153,7 +166,7 @@ HELP: <circular-clumps>
 { <clumps> <circular-clumps> <groups> } related-words
 
 HELP: monotonic?
-{ $values { "seq" sequence } { "quot" { $quotation "( elt1 elt2 -- ? )" } } { "?" "a boolean" } }
+{ $values { "seq" sequence } { "quot" { $quotation ( elt1 elt2 -- ? ) } } { "?" 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." }
 { $examples
     "Testing if a sequence is non-decreasing:"
@@ -163,11 +176,11 @@ HELP: monotonic?
 } ;
 
 HELP: all-equal?
-{ $values { "seq" sequence } { "?" "a boolean" } }
+{ $values { "seq" sequence } { "?" boolean } }
 { $description "Tests if all elements in the sequence are equal. Yields true with an empty sequence." } ;
 
 HELP: all-eq?
-{ $values { "seq" sequence } { "?" "a boolean" } }
+{ $values { "seq" sequence } { "?" boolean } }
 { $description "Tests if all elements in the sequence are the same identical object. Yields true with an empty sequence." } ;
 
 { monotonic? all-eq? all-equal? } related-words