lua-users home
lua-l archive

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




On Wednesday, April 9, 2014, Oliver Kroth <oliver.kroth@nec-i.de> wrote:
I agree Thomas,

and if I want to avoid the nil as result, I could either add my favourite minimum (maximum) to the argument list, or use short-circuit evaluation:

mimimum = min() or -math.huge
maximum = max() or  math.huge

-- Oliver

On 04/09/2014 12:27 PM, Dirk Laurie wrote:
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.

The only _numeric_ value. But if you define max(nil, y) to be y and min(nil, y) to be y as well you would have another value that would work for both functions.

--
Thomas




Yeah... Now I do have a preference:

math.max(math.huge) ~= math.max(nil)