Skip to content

Commit

Permalink
added node_count. version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro committed Aug 24, 2021
1 parent 54a3aab commit 82a1605
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 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.3"
version = "0.1.4"

[compat]
julia = "1"
9 changes: 8 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ Returns a single argument anonymous function predicate, that returns `true` if a
the argument to the predicate satisfies `isterm` and `gethead(x) == f`
"""
is_operation(f) = @nospecialize(x) -> isterm(x) && (gethead(x) == f)
export is_operation
export is_operation


"""
node_count(t)
Count the nodes in a symbolic expression tree satisfying `isterm` and `getargs`.
"""
node_count(t) = isterm(t) ? reduce(+, node_count(x) for x in getargs(t), init=0) + 1 : 1

2 comments on commit 82a1605

@0x0f0f0f
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

Added node_count

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/43456

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.4 -m "<description of version>" 82a1605b578c0e0a42dfde5715522beb22b41039
git push origin v0.1.4

Please sign in to comment.