rationals.anubis
482 Bytes
The Anubis Project.
Rational numbers.
public type Q:
q(Int numerator,
Int denominator).
public define Q
Q x + Q y
=
if x is q(xn,xd) then
if y is q(yn,yd) then
q(xn*yd+xd*yn,xd*yd).
public define Q
Q x * Q y
=
if x is q(xn,xd) then
if y is q(yn,yd) then
q(xn*yn,xd*yd).