Skip to content

How is 0.0:0.0:∞ handled? #117

@putianyi889

Description

@putianyi889

Currently this cannot be constructed with colons.

julia> 0.0:0.0:∞
ERROR: ArgumentError: InfStepRange must have infinite length
Stacktrace:
 [1] (::Colon)(start::Float64, step::Float64, stop::Infinities.Infinity)
   @ InfiniteArrays C:\Users\pty\.julia\dev\InfiniteArrays\src\infrange.jl:19
 [2] top-level scope
   @ REPL[40]:1

It can be generated using the type constructor or manipulating ranges.

julia> (1.0:∞)-(1.0:∞)
0.0:0.0:+∞

julia> InfStepRange(0.0,0.0)
0.0:0.0:+∞

julia> InfStepRange(0,0)
0:0:+

This is the same strategy that Julia Base uses. StepRangeLen is well defined for this purpose, while InfStepRange is ambiguous on what the stop should be.

julia> (1.0:5.0)-(1.0:5.0)
StepRangeLen(0.0, 0.0, 5)

julia> (1:5)-(1:5)
StepRangeLen(0, 0, 5)

InfUnitRange has a different pipeline.

julia> (1:∞)-(1:∞)
ℵ₀-element Fill{Int64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}} with indices OneToInf(), with entries equal to 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions