I was looking at the different possibilities for Expr to tree-like structure in Julia and thought of the Symbolics ecosystem as the natural modern place for it
I found an old post and GitHub - dfdx/Espresso.jl: Expression transformation package but was wondering if there is something in Symbolics
Expr is a tree structure. But @shashi might have some other tools.
True, it is a tree structure but I didnβt see the AbstractTree interface implemented anywhere.
Edit: no clue how I missed it, it is already built in AbstractTrees
julia> AbstractTrees.print_tree(:(3x + 2 * y - f(z + Ο)))
Expr(:call)
ββ :-
ββ Expr(:call)
β ββ :+
β ββ Expr(:call)
β β ββ :*
β β ββ 3
β β ββ :x
β ββ Expr(:call)
β ββ :*
β ββ 2
β ββ :y
ββ Expr(:call)
ββ :f
ββ Expr(:call)
ββ :+
ββ :z
ββ :Ο
1 Like