Load fixes for core/math
parent
b841dcc159
commit
f529d3d2d2
|
@ -44,10 +44,6 @@ HELP: odd?
|
|||
{ $values { "n" integer } { "?" "a boolean" } }
|
||||
{ $description "Tests if an integer is odd." } ;
|
||||
|
||||
HELP: fraction>
|
||||
{ $values { "a" integer } { "b" "a positive integer" } { "a/b" rational } }
|
||||
{ $description "Creates a new ratio, or outputs the numerator if the denominator is 1. This word does not reduce the fraction to lowest terms, and should not be called directly; use " { $link / } " instead." } ;
|
||||
|
||||
! Unsafe primitives
|
||||
HELP: fixnum+ ( x y -- z )
|
||||
{ $values { "x" fixnum } { "y" fixnum } { "z" integer } }
|
||||
|
|
|
@ -90,6 +90,9 @@ M: real hashcode* nip >fixnum ;
|
|||
|
||||
M: real <=> - ;
|
||||
|
||||
! real and sequence overlap. we disambiguate:
|
||||
M: integer <=> - ;
|
||||
|
||||
GENERIC: fp-nan? ( x -- ? )
|
||||
|
||||
M: object fp-nan?
|
||||
|
|
|
@ -3,8 +3,6 @@ IN: math.constants
|
|||
|
||||
ARTICLE: "math-constants" "Constants"
|
||||
"Standard mathematical constants:"
|
||||
{ $subsection i }
|
||||
{ $subsection -i }
|
||||
{ $subsection e }
|
||||
{ $subsection pi }
|
||||
"Various limits:"
|
||||
|
@ -14,12 +12,6 @@ ARTICLE: "math-constants" "Constants"
|
|||
|
||||
ABOUT: "math-constants"
|
||||
|
||||
HELP: i
|
||||
{ $values { "i" "the imaginary unit" } } ;
|
||||
|
||||
HELP: -i
|
||||
{ $values { "-i" "the negated imaginary unit" } } ;
|
||||
|
||||
HELP: e
|
||||
{ $values { "e" "base of natural logarithm" } } ;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
USING: help.markup help.syntax kernel math
|
||||
sequences quotations ;
|
||||
sequences quotations math.functions.private ;
|
||||
IN: math.functions
|
||||
|
||||
ARTICLE: "integer-functions" "Integer functions"
|
||||
|
|
|
@ -34,6 +34,10 @@ HELP: denominator ( a/b -- b )
|
|||
{ $values { "a/b" rational } { "b" "a positive integer" } }
|
||||
{ $description "Outputs the denominator of a rational number. Always outputs 1 with integers." } ;
|
||||
|
||||
HELP: fraction>
|
||||
{ $values { "a" integer } { "b" "a positive integer" } { "a/b" rational } }
|
||||
{ $description "Creates a new ratio, or outputs the numerator if the denominator is 1. This word does not reduce the fraction to lowest terms, and should not be called directly; use " { $link / } " instead." } ;
|
||||
|
||||
HELP: >fraction
|
||||
{ $values { "a/b" rational } { "a" integer } { "b" "a positive integer" } }
|
||||
{ $description "Extracts the numerator and denominator of a rational number." } ;
|
||||
|
|
|
@ -24,7 +24,7 @@ PRIVATE>
|
|||
|
||||
M: integer /
|
||||
dup zero? [
|
||||
/i
|
||||
"Division by zero" throw
|
||||
] [
|
||||
dup 0 < [ [ neg ] 2apply ] when
|
||||
2dup gcd nip tuck /i >r /i r> fraction>
|
||||
|
|
Loading…
Reference in New Issue