From a25ed8a75d036de252cfe74b5fa0788215194b41 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 2 May 2024 21:57:58 +0200 Subject: More math MAATHTHAHHAHA --- std/Math/Rational.bruijn | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'std/Math/Rational.bruijn') 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 -- cgit v1.2.3