From: Conrad Taylor
Subject: Rational arithmetic...???
Date:
Message-ID: <C4oDz5.uG@cs.uiuc.edu>
I was wondering, could one obtain the rational number package
that is used with MIT Scheme? For example, I have written a rational
package in which the internal representation of a rational number is
stored in list, 1/2 ==> (1 2), and two add two rational numbers one has
to type the following:
> (+rat 1 2 1 2) ==> 1
> (+rat 1 3 1 3) ==> (2 3)
> (+rat 2 8 4 8) ==> (3 4)
> (+rat 2 1 2 7) ==> (16 7)
> (make-rational 4 8) ==> (1 2)
However, in the MIT Scheme system, one can enter the following:
> (+ 1/2 1/2) ==> 1
> (+ 1/3 1/3) ==> 2/3
> (+ 2/8 4/8) ==> 3/4
> (+ 2 2/7) ==> 16/7
> 4/8 ==> 1/2
using ordinary addition. I'm using PC Scheme 3.03 and I would like
to be able to do the above as the MIT system. Thanks in advance and
please reply-to: ·······@silver.lcs.mit.edu. I would be more than
willing to redefine '+' if I have to.
-Conrad