Rational sequence

Ferenc Wagner wferi@afavant.elte.hu
Thu, 24 Oct 2002 16:50:14 +0200


"Simon Peyton-Jones" <simonpj@microsoft.com> writes:

> So I propose to modify the instance decl for Ratio by
> adding explicit defns for succ/pred just like those in
> Float/Double.

I bet you guessed: once at it, what about removing those
unintuitive 1/2-s, like:

numericEnumFromTo n m = takeWhile (<= m) (numericEnumFrom n)
numericEnumFromThenTo n n' m = takeWhile p (numericEnumFromThen n n')
                             where
                               p | n' > n    = (<= m + (n'-n))
                                 | otherwise = (>= m + (n'-n))

Everybody working with floats should know their quirks, while
Rationals should be treated exactly.

                                            Feri.