Skip to content

Order of elements matter of min/max #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pedroteixeira opened this issue Dec 7, 2014 · 2 comments
Closed

Order of elements matter of min/max #233

pedroteixeira opened this issue Dec 7, 2014 · 2 comments

Comments

@pedroteixeira
Copy link

It does not behave as expected:

Immutable.List.of(1, NaN).min() !=  Immutable.List.of(NaN, 1).min()

It would be really handy if NaN/null/undefined be ignored by max/min.

thanks.

@leebyron
Copy link
Collaborator

I think the behavior should be same as Math.max.apply(Math, list.toArray()) which is not order-dependent. So thanks for pointing out this discrepancy.

However, I'm not sure that NaN and friends should be ignored. NaN has significance when used in math operations - the result of a math operation in which NaN is an argument should always produce NaN. It's a way of bubbling error conditions up through nested operations.

@samwgoldman
Copy link
Contributor

100% agree that NaN should not be ignored. The max and min of a list containing NaN should be NaN, which is how Math.max and Math.min behave.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants