[racket-dev] feature request: gcd, lcm for rationals

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Dec 8 11:00:12 EST 2011

I'll make this change.

At Wed, 07 Dec 2011 12:25:34 -0500, David Van Horn wrote:
> It would be nice if gcd and lcm were extended to rational numbers, which 
> seems in-line with Scheme's philosophy (but not standards) on numbers.
> 
> (define (gcd-rational . rs)
>    (/ (apply gcd (map numerator rs))
>       (apply lcm (map denominator rs))))
> 
> (define (lcm-rational . rs)
>    (/ (abs (apply * rs))
>       (apply gcd-rational rs)))
> 
> David



Posted on the dev mailing list.