]> gitweb.factorcode.org Git - factor.git/commitdiff
math: [docs] add missing words, improve each-integer-from and all integers-from?
authorrazetime <raghuallthetime@hotmail.com>
Mon, 12 Dec 2022 13:06:15 +0000 (18:36 +0530)
committerrazetime <raghuallthetime@hotmail.com>
Mon, 12 Dec 2022 13:06:15 +0000 (18:36 +0530)
core/math/math-docs.factor
core/math/math.factor

index 1fdc0b01c64f5e09174a1094205f2edc1d1e377a..71ab869b34265643d2cd2299c2afdec4e84b98cd 100644 (file)
@@ -464,6 +464,54 @@ HELP: find-last-integer
 { $description "Applies the quotation to each integer from " { $snippet "n" } " down to 0, inclusive. Iteration stops when the quotation outputs a true value or 0 is reached. If the quotation yields a true value for some integer, the word outputs that integer. Otherwise, the word outputs " { $link f } "." }
 { $notes "This word is used to implement " { $link find-last } "." } ;
 
+HELP: all-integers-from?
+{ $values
+    { "from" integer } { "to" integer } { "quot" quotation }
+    { "?" boolean }
+}
+{ $description "Applies the quotation to each integer in " { $snippet "[from..to)" } ", returning " { $link t } " if all results are true, " and { $link f } " otherwise." } ;
+
+HELP: each-integer-from
+{ $values
+    { "from" integer } { "to" integer } { "quot" quotation }
+}
+{ $description "Applies the quotation to each integer in " { $snippet "[from..to)" } ", returning a list of all the results." } ;
+
+HELP: integer>fixnum
+{ $values
+    { "x" object }
+    { "y" object }
+}
+{ $description "Converts a general integer to a fixed-width integer." } ;
+
+HELP: integer>fixnum-strict
+{ $values
+    { "x" object }
+    { "y" object }
+}
+{ $description "Converts a general integer to a fixed-width integer." } ;
+
+HELP: log2-expects-positive
+{ $values
+    { "x" object }
+}
+{ $description "Throws a " { $link log2-expects-positive } " error." }
+{ $see-also log2 } ;
+
+HELP: neg?
+{ $values
+    { "x" object }
+    { "?" boolean }
+}
+{ $description "Pushes " { $link t } " if " { $snippet "x" } " is negative, else " { $link f } } ;
+
+HELP: simple-gcd
+{ $values
+    { "x" object } { "y" object }
+    { "d" object }
+}
+{ $description "" } ;
+
 ARTICLE: "division-by-zero" "Division by zero"
 "Behavior of division operations when a denominator of zero is used depends on the data types in question, as well as the platform being used."
 $nl
index 869d0aa133261075d9f419eb25d813d9f07d3770..308c211dc7d72e1d8dc085834aede75d82684022 100644 (file)
@@ -250,7 +250,7 @@ GENERIC: prev-float ( m -- n )
 : align ( m w -- n )
     1 - [ + ] keep bitnot bitand ; inline
 
-: each-integer-from ( ... i n quot: ( ... i -- ... ) -- ... )
+: each-integer-from ( ... from to quot: ( ... i -- ... ) -- ... )
     2over < [
         [ nip call ] 3keep
         [ 1 + ] 2dip each-integer-from
@@ -287,7 +287,7 @@ GENERIC: prev-float ( m -- n )
         ] if
     ] if ; inline recursive
 
-: all-integers-from? ( ... i n quot: ( ... i -- ... ? ) -- ... ? )
+: all-integers-from? ( ... from to quot: ( ... i -- ... ? ) -- ... ? )
     2over < [
         [ nip call ] 3keep roll
         [ [ 1 + ] 2dip all-integers-from? ]