diff --git a/src/comp.jl b/src/comp.jl index b586781..e0db7a4 100644 --- a/src/comp.jl +++ b/src/comp.jl @@ -22,10 +22,10 @@ end # Comparison of PolyVar function (==)(x::PolyVar{C}, y::PolyVar{C}) where C - x.id == y.id + x.id == y.id && x.name == y.name end -Base.isless(x::PolyVar{C}, y::PolyVar{C}) where C = isless(y.id, x.id) +Base.isless(x::PolyVar{C}, y::PolyVar{C}) where C = isless(x.name, y.name) # Comparison of Monomial diff --git a/src/var.jl b/src/var.jl index dcad083..6f424fb 100644 --- a/src/var.jl +++ b/src/var.jl @@ -42,14 +42,11 @@ macro ncpolyvar(args...) end struct PolyVar{C} <: AbstractVariable - id::Int + id::UInt name::String function PolyVar{C}(name::AbstractString) where {C} - # gensym returns something like Symbol("##42") - # we first remove "##" and then parse it into an Int - id = parse(Int, string(gensym())[3:end]) - new(id, convert(String, name)) + new(hash(name), convert(String, name)) end end