On 2020-07-04 at 20:33:36 +0100,
Regarding "[Python-ideas] Re: Add builtin function for min(max()),"
Henk-Jaap Wagenaar <wagenaarhenkj...@gmail.com> wrote:

> On Sat, 4 Jul 2020 at 19:58, Christopher Barker <python...@gmail.com> wrote:
> 
> > Hmm.
> >
> >
> > Since NaN is neither greater than nor less that anything, it seems the
> > only correct answer to any
> > Min,max,clamp involving a NaN is NaN.
> >
> >
> Simplifying the signature, in Python we have:
> 
> def min(*iterable):
>     iterator = iter(iterable)
>     minimum = next(iterable)
>     for item in iterator:
>         if item < minimum:
>             minimum = item
>     return minimum
> 
> Due to this, min(0, float('nan')) == 0 and same for max. I would hence
> expect clamp to behave similarly.

Yuck:  We also have min(float('nan'), 0) == float('nan').

I'm not sure what I'd expect a hypothetical clamp function to do.
Someone with actual use cases will have more insight.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/K4STFFKEJG7RTF2UTGWI3ILZ3UVQMOPO/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to