[r6rs-discuss] [Formal] Max and min with zero arguments
Pete wrote:
> On 12/13/06, John Cowan <cowan at ccil.org> wrote:
>> In R5RS the max and min functions must take at least one argument,
>> because there is no universal maximum or minimum. In R6RS, however,
>> we have +0.inf and -0.inf. I suggest, therefore, that (max) => -0.inf
>> and (min) => +0.inf. This also allows multiple-argument max and min
>> to be defined using a fold primitive ver two-argument versions.
>
> I can already see a problem with this. +0.inf and -0.inf are
> inexacts. Since e.g.
>
> (max 3.9 4) => 4.0 (see section 9.10.2.3)
>
> this would cause max and min to always return inexact numbers. This
> is definitely not desirable.
However min/max arguments may be implicitly considered to have been
consistently compared against huge (exact?) infinites if defined as
values whose magnitude exceed the practical representational limit of
an exact value implementation and correspondingly defined as having a
greater magnitude than their inexact counterparts; thereby:
(min) :: (min +inf) => +inf
(max) :: (min -inf) => -inf
(min +inf.0) :: (min +inf.0 +inf) => +inf.0
(max -inf.0) :: (max -inf.0 -inf) => -inf.0
and min/max defined as returning the argument having a value <=/>= all
successive arguments having the precision of the least precise argument
if otherwise comparing =; thereby further:
(min 0 1.0) :: (min 0 1.0 +inf) => 0
(min 0 0.0) :: (min 0 0.0 +inf) => 0.0
and thereby an implementation may also now return a formal value for
calculations which may otherwise overflow the practical limits of a given
exact implementation and be consistently distinguishable from their inexact
counterparts, rather than risk potentially overflowing memory and bringing
the system down.
as just a thought.
Received on Sun Dec 17 2006 - 12:56:25 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:00 UTC