From b1062132fc1c2f3fb3b925fb42acc5de7a33f6d3 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 13 Apr 2024 20:08:09 +0200 Subject: Worked on real numbers --- std/Math/Rational.bruijn | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'std/Math/Rational.bruijn') diff --git a/std/Math/Rational.bruijn b/std/Math/Rational.bruijn index 4c2f046..1f8a8ec 100644 --- a/std/Math/Rational.bruijn +++ b/std/Math/Rational.bruijn @@ -8,6 +8,11 @@ :import std/Pair . :import std/Math N +# converts a balanced ternary number to a rational number +number→rational [0 : (+0)] ⧗ Number → Rational + +:test (number→rational (+5)) ((+5.0)) + # returns true if two rational numbers are equal eq? &[[&[[N.eq? (N.mul 3 N.++0) (N.mul N.++2 1)]]]] ⧗ Rational → Rational → Boolean -- cgit v1.2.3