[erlang-questions] Inf, NaN, and -Inf

Tom Burdick thomas.burdick@REDACTED
Mon Feb 27 20:28:03 CET 2012


What I actually need, for clarification is...

minmax({Min, Max}, Values) ->
    {min(lists:min(Values), Min), max(lists:max(Values), Max)}

Except I'd like to be able to set some Min, Max value before ever getting
values that still makes sense in javascript as well as erlang and still
works with the above situation.

minmax is repeatedly called with a new list of values that are generated
from some source like a user supplied CSV file without any known value
range, and is far too large to fit entirely in memory.

I hope this helps to understand the problem. With erlang it appears I'd
need a special case now.

minmax({inf, -inf}, Values) ->
    {lists:min(Values), lists:max(Values)};
minmax({Min, Max}, Values) ->
    {min(lists:min(Values), Min), max(lists:max(Values), Max)}.

In other languages that special case isn't necessary because min and max
work with IEEE inf and - inf as expected.

Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120227/81bf45e5/attachment.htm>


More information about the erlang-questions mailing list