]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/math/extras/extras-docs.factor
factor: trim using lists
[factor.git] / extra / math / extras / extras-docs.factor
index cd477f8354f008da1996889cc77f4db5ca313d1a..bf599371d2eb360e6f90eced88d8fa4a7872b5e6 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2012 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: help.markup help.syntax kernel math sequences ;
+USING: help.markup help.syntax kernel math math.functions
+sequences ;
 
 IN: math.extras
 
@@ -58,19 +59,19 @@ HELP: sinc
 { $description "Returns the " { $link sinc } " function, calculated according to " { $snippet "sin(pi * x) / (pi * x)" } ". The name " { $link sinc } " is short for \"sine cardinal\" or \"sinus cardinalis\"." }
 { $notes { $snippet "0 sinc" } " is the limit value of 1." } ;
 
-HELP: linspace[a,b)
+HELP: linspace[a..b)
 { $values { "a" number } { "b" number } { "length" integer } { "seq" sequence } }
 { $description "Return evenly spaced numbers over an interval " { $snippet "[a,b)" } "." } ;
 
-HELP: linspace[a,b]
+HELP: linspace[a..b]
 { $values { "a" number } { "b" number } { "length" integer } { "seq" sequence } }
 { $description "Return evenly spaced numbers over an interval " { $snippet "[a,b]" } "." } ;
 
-HELP: logspace[a,b)
+HELP: logspace[a..b)
 { $values { "a" number } { "b" number } { "length" integer } { "base" number } { "seq" sequence } }
 { $description "Return evenly spaced numbers on a log scaled interval " { $snippet "[base^a,base^b)" } "." } ;
 
-HELP: logspace[a,b]
+HELP: logspace[a..b]
 { $values { "a" number } { "b" number } { "length" integer } { "base" number } { "seq" sequence } }
 { $description "Return evenly spaced numbers on a log scaled interval " { $snippet "[base^a,base^b]" } "." } ;
 
@@ -78,6 +79,18 @@ HELP: majority
 { $values { "seq" sequence } { "elt/f" object } }
 { $description "Returns the element of " { $snippet "seq" } " that is in the majority, provided there is such an element, using a linear-time majority vote algorithm." } ;
 
+HELP: nonzero
+{ $values { "seq" sequence } { "seq'" sequence } }
+{ $description "Outputs a new sequence of the same type as " { $snippet "seq" } " with all non-zero elements removed." } ;
+
+HELP: round-away-from-zero
+{ $values { "x" number } { "y" number } }
+{ $description "Rounds " { $snippet "x" } " via " { $link ceiling } " if " { $snippet "x" } " is greater than zero, and " { $link floor } " if x is less than zero." }
+{ $examples
+    { $example "USING: math.extras prettyprint ;" "0.5 round-away-from-zero ." "1.0" }
+    { $example "USING: math.extras prettyprint ;" "-0.5 round-away-from-zero ." "-1.0" } }
+{ $see-also ceiling floor } ;
+
 HELP: round-to-decimal
 { $values { "x" real } { "n" integer } { "y" real } }
 { $description "Outputs the number closest to " { $snippet "x" } ", rounded to " { $snippet "n" } " decimal places." }
@@ -86,3 +99,7 @@ HELP: round-to-decimal
     { $example "USING: math.extras prettyprint ;" "1.23456 2 round-to-decimal ." "1.23" }
     { $example "USING: math.extras prettyprint ;" "12345.6789 -3 round-to-decimal ." "12000.0" }
 } ;
+
+HELP: kahan-sum
+{ $values { "seq" sequence } { "n" float } }
+{ $description "Calculates the summation of the sequence using the Kahan summation algorithm." } ;