Skip to content

Commit

Permalink
size, length, iterate, isempty, in, map for Ring elements
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausC committed Jan 16, 2024
1 parent 4cf9363 commit e14beca
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ for op in (:+, :-, :*, :/, :\, :isapprox)
end

# generic operations

Base.IteratorSize(::Ring) = Base.HasShape{0}()
Base.size(::Ring) = ()
Base.length(::Ring) = 1
Base.iterate(r::Ring) = (r, nothing)
Base.iterate(::Ring, ::Any) = nothing
Base.isempty(::Ring) = false
Base.in(a::Ring, b::Ring) = a == b
Base.map(f, a::Ring, bs::Ring...) = f(a, bs...)

basetype(::T) where T<:Ring = basetype(T)
basetype(::Type{T}) where T = Union{}
basetype(::Type{Union{}}) = Union{}
Expand Down

0 comments on commit e14beca

Please sign in to comment.