[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: math.min, math.max
- From: Tim Hill <drtimhill@...>
- Date: Wed, 9 Apr 2014 13:32:20 -0700
On Apr 9, 2014, at 3:27 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2014-04-09 12:15 GMT+02:00 Oliver Kroth <oliver.kroth@nec-i.de>:
>> Is this so?
>>
>> I would expect the minimum or maximum element of the argument list to be
>> returned as result.
>> With an empty list, I would not be confused to get nil.
>
> It's the same principle by which when n<1,
>
> 1 + 2 + 3 + ... + n
>
> evaluates to 0 and
>
> 1 * 2 * 3 * ... * n
>
> evaluates to 1.
>
> max satisfies relationships like: max(a,b,c,d) = max(max(a,b),max(c,d)),
> no matter how you split up the arguments. For a consistent definition
> of max(), you need max(a,b,c,d) = max(max(),max(a,b,c,d)). But the
> only value of x for which always y = max(x,y) is x=-math.huge.
>
> At present you don't get nil, you get an error.
>
But max(a,b,c) will always return _one_ of the actual values passed in. max() by itself doesn’t get passed any values, so generating math.huge out of nothing seems inconsistent as well.
—Tim