TreeForm[HoldForm[ (9-2^2+10 8)/9]]
produces this:
Is there a way to use Divide
instead of Power
to $-1$ and delete the "HoldForm" node or change it another string? Change the "Times", "Plus", etc. nodes to the result of the operation?
I'm trying to make trees illustrating the order of operations.
Subtract
andDivide
are automagically converted (see their respective doc pages for details), but have a look atExpressionTree[Unevaluated[(9 - 2^2 + 10 8)/9]]
. $\endgroup$Hold[(9 - 2^2 + 10 8)/9] /. Times[x_, Power[b_, -1]] :> HoldForm[Divide][x, b] /. op : Plus | Times | Power -> HoldForm[op] // First // TreeForm
$\endgroup$