From 89e3cc511e576254b78e8302a8eaff5066966981 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sun, 19 Jul 2015 15:59:40 -0700 Subject: [PATCH] math: moving >fraction to math. --- basis/math/functions/functions.factor | 6 ------ basis/math/ratios/ratios.factor | 1 + core/math/integers/integers.factor | 1 + core/math/math.factor | 1 + 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/basis/math/functions/functions.factor b/basis/math/functions/functions.factor index dd1f797074..6b1382fa1a 100644 --- a/basis/math/functions/functions.factor +++ b/basis/math/functions/functions.factor @@ -4,12 +4,6 @@ USING: math kernel math.constants math.private math.bits math.libm combinators fry math.order sequences ; IN: math.functions -GENERIC: >fraction ( a/b -- a b ) - -M: integer >fraction 1 ; inline - -M: ratio >fraction [ numerator ] [ denominator ] bi ; inline - : rect> ( x y -- z ) ! Note: an imaginary 0.0 should still create a complex dup 0 = [ drop ] [ complex boa ] if ; inline diff --git a/basis/math/ratios/ratios.factor b/basis/math/ratios/ratios.factor index 70969cad43..5d693ec5e7 100644 --- a/basis/math/ratios/ratios.factor +++ b/basis/math/ratios/ratios.factor @@ -63,6 +63,7 @@ M: ratio >float >fraction /f ; M: ratio numerator numerator>> ; inline M: ratio denominator denominator>> ; inline +M: ratio >fraction [ numerator ] [ denominator ] bi ; inline M: ratio < scale < ; M: ratio <= scale <= ; diff --git a/core/math/integers/integers.factor b/core/math/integers/integers.factor index 7cc3b3448f..bee5cf6325 100644 --- a/core/math/integers/integers.factor +++ b/core/math/integers/integers.factor @@ -12,6 +12,7 @@ IN: math.integers M: integer numerator ; inline M: integer denominator drop 1 ; inline +M: integer >fraction 1 ; inline M: fixnum >fixnum ; inline M: fixnum >bignum fixnum>bignum ; inline diff --git a/core/math/math.factor b/core/math/math.factor index 600c1d7efc..5a0ba2fd46 100644 --- a/core/math/math.factor +++ b/core/math/math.factor @@ -84,6 +84,7 @@ GENERIC: integer>fixnum-strict ( x -- y ) foldable GENERIC: numerator ( a/b -- a ) GENERIC: denominator ( a/b -- b ) +GENERIC: >fraction ( a/b -- a b ) GENERIC: real-part ( z -- x ) GENERIC: imaginary-part ( z -- y )