Skip to content

Commit 88bef2a

Browse files
YingboMashashi
andcommitted
mv
Co-authored-by: "Shashi Gowda" <[email protected]>
1 parent 8962944 commit 88bef2a

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/types.jl

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,6 @@ Base.isequal(::Symbolic, x) = false
106106
Base.isequal(x, ::Symbolic) = false
107107
Base.isequal(::Symbolic, ::Symbolic) = false
108108

109-
function Base.isequal(a::Sym, b::Sym)
110-
symtype(a) !== symtype(b) && return false
111-
isequal(nameof(a), nameof(b))
112-
end
113-
114-
function Base.isequal(t1::Term, t2::Term)
115-
t1 === t2 && return true
116-
symtype(t1) !== symtype(t2) && return false
117-
118-
a1 = arguments(t1)
119-
a2 = arguments(t2)
120-
121-
isequal(operation(t1), operation(t2)) &&
122-
length(a1) == length(a2) &&
123-
all(isequal(l,r) for (l, r) in zip(a1,a2))
124-
end
125109

126110
### End of interface
127111

@@ -189,7 +173,10 @@ end
189173

190174
Base.hash(s::Sym{T}, u::UInt) where {T} = hash(T, hash(s.name, u))
191175

192-
Base.isequal(v1::Sym{T}, v2::Sym{T}) where {T} = v1 === v2
176+
function Base.isequal(a::Sym, b::Sym)
177+
symtype(a) !== symtype(b) && return false
178+
isequal(nameof(a), nameof(b))
179+
end
193180

194181
Base.show(io::IO, v::Sym) = Base.show_unquoted(io, v.name)
195182

@@ -349,6 +336,18 @@ operation(x::Term) = getfield(x, :f)
349336

350337
arguments(x::Term) = getfield(x, :arguments)
351338

339+
function Base.isequal(t1::Term, t2::Term)
340+
t1 === t2 && return true
341+
symtype(t1) !== symtype(t2) && return false
342+
343+
a1 = arguments(t1)
344+
a2 = arguments(t2)
345+
346+
isequal(operation(t1), operation(t2)) &&
347+
length(a1) == length(a2) &&
348+
all(isequal(l,r) for (l, r) in zip(a1,a2))
349+
end
350+
352351
## This is much faster than hash of an array of Any
353352
hashvec(xs, z) = foldr(hash, xs, init=z)
354353

@@ -379,7 +378,6 @@ function _promote_symtype(f, args)
379378
end
380379
end
381380

382-
383381
function term(f, args...; type = nothing)
384382
if type === nothing
385383
T = _promote_symtype(f, args)

0 commit comments

Comments
 (0)