From 9f9e7ec6353fc66c40d7950fc7a5f36547eec727 Mon Sep 17 00:00:00 2001 From: there# <84727708+ForgottenGensym@users.noreply.github.com> Date: Tue, 1 Jun 2021 09:26:35 -0400 Subject: [PATCH 1/4] Potential fix (#1107) --- src/List.elm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/List.elm b/src/List.elm index 83f411c0..ac59e144 100644 --- a/src/List.elm +++ b/src/List.elm @@ -62,7 +62,11 @@ singleton value = -} repeat : Int -> a -> List a repeat n value = - repeatHelp [] n value + if isInfinite n then + [] + + else + repeatHelp [] n value repeatHelp : List a -> Int -> a -> List a From b9aeae895dd84f1f3adc06aae61d1825785aa282 Mon Sep 17 00:00:00 2001 From: there# <84727708+ForgottenGensym@users.noreply.github.com> Date: Tue, 1 Jun 2021 09:33:20 -0400 Subject: [PATCH 2/4] add _Basics_is(Positive|Negative)Infinity (#1107) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This isn’t a fix for #1107, but a part of a potential one. These `Kernel.Basics` functions will allow a more optimized solution to the `List.repeat` problem --- src/Elm/Kernel/Basics.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Elm/Kernel/Basics.js b/src/Elm/Kernel/Basics.js index 049291f9..f0ee5e82 100644 --- a/src/Elm/Kernel/Basics.js +++ b/src/Elm/Kernel/Basics.js @@ -47,6 +47,8 @@ var _Basics_atan2 = F2(Math.atan2); function _Basics_toFloat(x) { return x; } function _Basics_truncate(n) { return n | 0; } function _Basics_isInfinite(n) { return n === Infinity || n === -Infinity; } +function _Basics_isPositiveInfinity(n) { return n === Infinity; } +function _Basics_isNegativeInfinity(n) { return n === -Infinity; } var _Basics_ceiling = Math.ceil; var _Basics_floor = Math.floor; From 70a0f1541f41e7a41c3c846d1d018231266dab19 Mon Sep 17 00:00:00 2001 From: there# <84727708+ForgottenGensym@users.noreply.github.com> Date: Tue, 1 Jun 2021 09:40:26 -0400 Subject: [PATCH 3/4] add `is(Negative|Positive)Infinity` (elm) (#1107) Part of a potential fix #1107 (optimized version). --- src/Basics.elm | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Basics.elm b/src/Basics.elm index 477048bd..4ef740d7 100644 --- a/src/Basics.elm +++ b/src/Basics.elm @@ -10,7 +10,7 @@ module Basics exposing , pi, cos, sin, tan, acos, asin, atan, atan2 , degrees, radians, turns , toPolar, fromPolar - , isNaN, isInfinite + , isNaN, isInfinite, isPositiveInfinity, isNegativeInfinity , identity, always, (<|), (|>), (<<), (>>), Never, never ) @@ -52,7 +52,7 @@ things. @docs toPolar, fromPolar # Floating Point Checks -@docs isNaN, isInfinite +@docs isNaN, isInfinite, isPositiveInfinity, isNegativeInfinity # Function Helpers @docs identity, always, (<|), (|>), (<<), (>>), Never, never @@ -828,6 +828,27 @@ isInfinite = Elm.Kernel.Basics.isInfinite +{-| Determine whether a float is equal to positive infinity. + + isPositiveInfinity 1 == False + isPositiveInfinity (1/0) == True + isPositiveInfinity -(1/0) == False +-} +isPositiveInfinity : Float -> Bool +isPositiveInfinity = + Elm.Kernel.Basics.isPositiveInfinity + + +{-| Determine whether a float is equal to positive infinity. + + isNegativeInfinity 1 == False + isNegativeInfinity (1/0) == False + isNegativeInfinity -(1/0) == True +-} +isNegativeInfinity : Float -> Bool +isNegativeInfinity = + Elm.Kernel.Basics.isNegativeInfinity + -- FUNCTION HELPERS From d0e85249a52d81f6cb97667aabc70e7533671e79 Mon Sep 17 00:00:00 2001 From: there# <84727708+ForgottenGensym@users.noreply.github.com> Date: Tue, 1 Jun 2021 09:41:32 -0400 Subject: [PATCH 4/4] Potential fix (#1107) (optimized version) --- src/List.elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/List.elm b/src/List.elm index ac59e144..ab9e92a2 100644 --- a/src/List.elm +++ b/src/List.elm @@ -62,7 +62,7 @@ singleton value = -} repeat : Int -> a -> List a repeat n value = - if isInfinite n then + if isPositiveInfinity n then [] else