Skip to content
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

Fix #1107 (optimized version) #1113

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/Basics.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions src/Elm/Kernel/Basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/List.elm
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ singleton value =
-}
repeat : Int -> a -> List a
repeat n value =
repeatHelp [] n value
if isPositiveInfinity n then
[]

else
repeatHelp [] n value


repeatHelp : List a -> Int -> a -> List a
Expand Down