]> gitweb.factorcode.org Git - factor.git/blobdiff - core/sequences/sequences-docs.factor
Fix conflict
[factor.git] / core / sequences / sequences-docs.factor
index a753e478bf2a718e22cbbc09be01c8b3ef106321..7cf83d2e37f3672990f35079d3eeb6cd39a732a7 100755 (executable)
@@ -1,6 +1,5 @@
 USING: arrays help.markup help.syntax math
-sequences.private vectors strings sbufs kernel math.order
-layouts ;
+sequences.private vectors strings kernel math.order ;
 IN: sequences
 
 ARTICLE: "sequences-unsafe" "Unsafe sequence operations"
@@ -959,3 +958,23 @@ HELP: unfold
     "The " { $snippet "tail" } " quotation is used when the predicate produces more than one output value. In this case, we have to drop this value even if the predicate fails in order for stack inference to calculate a stack effect for the " { $link unfold } " call:"
     { $unchecked-example "USING: kernel prettyprint random sequences ;" "[ 10 random dup 1 > ] [ ] [ drop ] unfold ." "{ 8 2 2 9 }" }
 } ;
+
+HELP: sigma
+{ $values { "seq" sequence } { "quot" quotation } { "n" number } }
+{ $description "Like map sum, but without creating an intermediate sequence." }
+{ $example
+    "! Find the sum of the squares [0,99]"
+    "USING: math math.ranges sequences.lib prettyprint ;"
+    "100 [1,b] [ sq ] sigma ."
+    "338350"
+} ;
+
+HELP: count
+{ $values { "seq" sequence } { "quot" quotation } { "n" integer } }
+{ $description "Efficiently returns the number of elements that the predicate quotation matches." }
+{ $example
+    "USING: math math.ranges sequences.lib prettyprint ;"
+    "100 [1,b] [ even? ] count ."
+    "50"
+} ;
+