[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bounded, infinite ranges?



Andy Wilson writes:
/// Scot Dyer writes:
/// ---------------------------------------------------------------------
/// /// Again, these unpleasant facts of floating point life could be avoided
/// /// if from/up-to/by were constrained to be <rational>.
/// 
/// I think even <rational> might have it's problems...
/// ---------------------------------------------------------------------
/// 
/// Rational arithmetic is always exact; maybe not fast, but exact.

Yes, but enumerating a finite rational range would be quite time-intensive, and
would require some special form, since it wouldn't (in all probability) fit in
memory on most machines.  Also, generating the members of a rational range in
sequential order (each new one greater or lesser for the whole range) is more
of a trick than for floats (in my eyes -- but my experience w/ rationals is
limitted)

I do agree that = should be defined for rationals, tho'.  And for indexed
loops (ala 'for') a rational restriction is probably best.  Either that, or
something like C's for, which would really be a 'while' extension.  Since the
iteration methods are defined for collections, a special version of 'for' could
be provided, like '(over <collection> <form>)' (for-each w/ <collection>?)

	-- Scot