1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-11-19 06:30:29 +01:00

add missing constructors and converts

This commit is contained in:
kalmarek 2020-03-25 05:21:57 +01:00
parent f8aedc207f
commit 12be3b75bc
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
3 changed files with 7 additions and 1 deletions

View File

@ -18,3 +18,4 @@ function (==)(s::GSymbol, t::GSymbol)
end
Base.convert(::Type{GS}, s::GSymbol) where GS<:GSymbol = GS(s.id, s.pow)
Base.convert(::Type{GS}, s::GS) where GS<:GSymbol = s

View File

@ -34,7 +34,10 @@ mutable struct GroupWord{T} <: GWord{T}
savedhash::UInt
parent::Group
function GroupWord{T}(symbols::Vector{<:GSymbol}) where T
function GroupWord{T}(symbols::AbstractVector{<:GSymbol}) where T
return new{T}(symbols, true, zero(UInt))
end
GroupWord(v::AbstractVector{T}) where T<:GSymbol = GroupWord{T}(v)
GroupWord{T}(s::GSymbol) where T<:GSymbol = GroupWord{T}(T[s])
GroupWord(s::T) where T<:GSymbol = GroupWord{T}(s)
end

View File

@ -37,3 +37,5 @@ Base.@propagate_inbounds function Base.getindex(w::GWord, i::Integer)
end
# no setindex! for syllable based words
Base.convert(::Type{GW}, s::GSymbol) where GW <: GWord = GW(s)