Skip to content

Commit

Permalink
Merge pull request #5 from JuliaSymbolics/s/sym
Browse files Browse the repository at this point in the history
add a default issym, make it work on types
  • Loading branch information
shashi authored Aug 30, 2021
2 parents def31aa + c7cec41 commit 8d03c71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TermInterface"
uuid = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c"
authors = ["Shashi Gowda <[email protected]>", "Alessandro Cheli <[email protected]>"]
version = "0.1.7"
version = "0.1.8"

[compat]
julia = "1"
5 changes: 3 additions & 2 deletions src/TermInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export symtype
Returns `true` if `x` is a symbol. If true, `nameof` must be defined
on `x` and must return a Symbol.
"""
function issym end
issym(x) = issym(typeof(x))
issym(x::Type{T}) where {T} = false
export issym

"""
Expand Down Expand Up @@ -96,7 +97,7 @@ similarterm(x, head, args, symtype=nothing; metadata=nothing) =
similarterm(x::Type{Expr}, head, args, symtype=nothing; metadata=nothing) = Expr(head, args...)

function similarterm(x::Type{T}, head, args, symtype=nothing; metadata=nothing) where T
if !istree(T) head else head(args...) end
!istree(T) ? head : head(args...)
end
export similarterm

Expand Down

0 comments on commit 8d03c71

Please sign in to comment.