Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does elm have a constant for infinity?

Tags:

math

infinity

elm

According to this: http://package.elm-lang.org/packages/elm-lang/core/latest/Basics#isNaN

Elm supports infinity and considers it a number. Right now I am using inf = 1/0 as a constant but I want to know how I can import infinity, instead of defining it.

So, does Elm have a constant for infinity and how do I import it?

like image 543
mand Avatar asked Oct 20 '25 05:10

mand


1 Answers

I see you already have an answer, but here is one way to emulate inifinty using a Maybe

infinity =
    Nothing


lessThan : Int -> Maybe Int -> Maybe Int
lessThan x y =
    case y of
        Just y_ ->
            if x < y_ then
                Just x

            else
                y

        Nothing ->
            Just x
like image 183
Simon H Avatar answered Oct 22 '25 05:10

Simon H