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

Tom Burdick thomas.burdick@REDACTED
Mon Feb 27 20:40:24 CET 2012


After thinking a little harder I think this is just a case of me
trying to translate prior thought out code in another language to
erlang without attempting to think too hard on it.

I figured it out. Thanks!

-Tom

On Mon, Feb 27, 2012 at 1:28 PM, Tom Burdick <thomas.burdick@REDACTED> wrote:
> 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
>
>
>
>
>
>
>



More information about the erlang-questions mailing list