代码拉取完成,页面将自动刷新
# This file is a part of Julia. License is MIT: https://julialang.org/license
# InfiniteArrays (arrays with infinite size)
# This test file is designed to exercise support for generic sizing,
# even though infinite arrays aren't implemented in Base.
module InfiniteArrays
export OneToInf, Infinity
"""
Infinity()
represents infinite cardinality. Note that `Infinity <: Integer` to support
being treated as an index.
"""
struct Infinity <: Integer end
Base.:(==)(::Infinity, ::Int) = false
Base.:(==)(::Int, ::Infinity) = false
Base.:(<)(::Int, ::Infinity) = true
Base.:(≤)(::Int, ::Infinity) = true
Base.:(<)(::Infinity, ::Int) = false
Base.:(≤)(::Infinity, ::Int) = false
Base.:(≤)(::Infinity, ::Infinity) = true
Base.:(-)(::Infinity, ::Int) = Infinity()
Base.:(+)(::Infinity, ::Int) = Infinity()
Base.:(:)(::Infinity, ::Infinity) = 1:0
Base.max(::Infinity, ::Int) = Infinity()
Base.max(::Int, ::Infinity) = Infinity()
"""
OneToInf()
Define an `AbstractInfUnitRange` that behaves like `1:∞`, with the added
distinction that the limits are guaranteed (by the type system) to
be 1 and ∞.
"""
struct OneToInf{T<:Integer} <: Base.AbstractOneTo{T} end
OneToInf() = OneToInf{Int}()
Base.axes(r::OneToInf) = (r,)
Base.size(r::OneToInf) = (Infinity(),)
Base.first(r::OneToInf{T}) where {T} = oneunit(T)
Base.length(r::OneToInf) = Infinity()
Base.last(r::OneToInf) = Infinity()
Base.unitrange(r::OneToInf) = r
Base.oneto(::Infinity) = OneToInf()
Base.unchecked_oneto(::Infinity) = OneToInf()
end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。