From 12be3b75bc50309ddc219158171120803ca32470 Mon Sep 17 00:00:00 2001 From: kalmarek Date: Wed, 25 Mar 2020 05:21:57 +0100 Subject: [PATCH] add missing constructors and converts --- src/symbols.jl | 1 + src/types.jl | 5 ++++- src/words.jl | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/symbols.jl b/src/symbols.jl index 7989fdc..dd766ff 100644 --- a/src/symbols.jl +++ b/src/symbols.jl @@ -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 diff --git a/src/types.jl b/src/types.jl index 320b04f..1de0a34 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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 diff --git a/src/words.jl b/src/words.jl index ab08337..9ef7383 100644 --- a/src/words.jl +++ b/src/words.jl @@ -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)