10 questions linked to/from ReplaceRepeated seemingly omits some rules
5k views

### Levels: how do they work?

I cannot understand how Mathematica manages levels, and so it's always a painful try-and-fail to use Flatten. Can someone please give me a very clear definition? ...
• 1,617
2k views

### How to perform a depth-first preorder traversal of an expression?

Mathematica provides functions that perform a depth-first postorder traversal, or which use such a traversal, including: Scan, ...
• 272k
5k views

### Determine whether some expression contains a given symbol

Given a symbol t and an expression expr, how can I determine whether or not the symbol t ...
• 1,859
3k views

### Using ReplaceAll to replace a head

Why would this work to replace the head b with newHead: ...
• 5,121
286 views

### Prevent testing Head with ReplaceAll

I have a list of strings list. I am trying to get rid of some elements that match string pattern patt: ...
• 637
1k views

### What do brackets around a levelspec option do?

The following code returns the first three integer elements of Sqrt[Range[100]]: ...
• 1,471
158 views

### Why Graph does not recognize chains of vertexes like NetGraph

Cross posted on Wolfram Community. Perfect logic: NetGraph[{1, 1, 1}, {1 -> 2 -> 3}] But this does not make sense: ...
• 2,060
191 views

### Is Replace doing double work?

In an answer to this question, rm -rf used the function Replace with level spefication to do a series of replacements inside out. As far as I can see, the order of substitutions when more than one ...
• 10.2k
223 views

### How to make a postordered ReplaceAll that operates just once per subtree?

The answers to this question provide code for a function I'll call postOrderReplaceAll to replace from the inside-out: ...
• 434