Julia expression to AbstractTree-like structure in Symbolics

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