7
votes
Accepted
6
votes
Accepted
How to make a postordered ReplaceAll that operates just once per subtree?
Based on my understanding of the question, you want to apply the rule to any expression, provided it wouldn't match any of its subexpressions.
You can implement this traversal yourself quite easily ...
5
votes
How to perform a breadth-first traversal of an expression?
I don't sure this will look as a duplicated version with Sjoerd C. de Vries in here,but there are some trick function can make you life ease and simplify that answer.So I post this answer still.
Build ...
4
votes
Accepted
How to mark leaves of polynomial based on its position in tree
Here's a first attempt, I wouldn't be surprised if a sufficiently complicated monomial group fails to expand under this:
First, a helper function: We need to be able to determine the order of a ...
3
votes
a function to extract all subexpressions from an expression
Second answer
The OP's desired order:
...
2
votes
Visiting nodes in a tree bottom up
If it is okay for the properties to be updated in a post-order depth-first traversal, you can use TreeFold:
...
1
vote
How to mark leaves of polynomial based on its position in tree
MinimumVertexColoring
Constructing an adjacency graph (two variables are adjacent if they appear in the same term in the expansion of the polynomial) and using ...
1
vote
a function to extract all subexpressions from an expression
Your use of the head Inactive[] complicates this a bit, but generally, you'll want to do this:
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
traversal × 12trees × 4
list-manipulation × 3
graphs-and-networks × 2
programming × 2
functions × 1
function-construction × 1
bugs × 1
mathematical-optimization × 1
replacement × 1
expression-manipulation × 1
combinatorics × 1
algorithm × 1
rule × 1
expression-construction × 1