diff options
Diffstat (limited to 'std/Math/Rational.bruijn')
-rw-r--r-- | std/Math/Rational.bruijn | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/std/Math/Rational.bruijn b/std/Math/Rational.bruijn index 54c3a88..f1509b0 100644 --- a/std/Math/Rational.bruijn +++ b/std/Math/Rational.bruijn @@ -3,6 +3,7 @@ # (p : q) ⇔ (1 / (q + 1)) +:import std/Logic . :import std/Combinator . :import std/Logic . :import std/Pair . @@ -91,6 +92,10 @@ div [[1 ⋅ ~0]] ⧗ Rational → Rational → Rational :test ((+8.0) / (+4.0) =? (+2.0)) (true) :test ((+18.0) / (+12.0) =? (+1.5)) (true) +gt? &[[&[[(N.gt? 1 3) ⋀? (N.gt? 0 2)]]]] + +lt? &[[&[[(N.lt? 1 3) ⋀? (N.lt? 0 2)]]]] + # increments a rational number inc add (+1.0) ⧗ Rational → Rational @@ -106,4 +111,4 @@ dec \sub (+1.0) ⧗ Rational → Rational :import std/List L # power function: rational^number -pow-n [L.…!!… (L.iterate (mul 0) (+1.0))] ⧗ Rational → Number → Rational +pow-n [L.nth-iterate (mul 0) (+1.0)] ⧗ Rational → Number → Rational |