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, ...
536 views

### Replace heads to match a pattern

Is it possible to replace the heads to match a pattern? eg f[f[f[]]] -> a[b[c[]]] or ...
28k views

### How to remove redundant {} from a nested list of lists?

There are numerous examples here, whose end result is the removal of empty brackets {} and empty lists. I still can't find an example of simply removing redundant ...
2k views

### Converting hierarchies of rules to associations

The impossibility of MatchQ-ing inside and Association MatchQ-ing Associations (MMA 10) explains a problem I have. I would like ...
225 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: ...
4k 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 ...
535 views

### ReplaceRepeated seemingly omits some rules

Is there a simple way in Mathematica to prevent rule reordering? Let me give an example: ...
256 views

### Unexpected behavior using ReplaceAll[] for nested lists [duplicate]

ReplaceAll[] might lead to unexpected behavior (at least it surprised me). I use ReplaceAll[] to convert a list (basically data ...
176 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 ...
80 views

### Slow replacement rule while combining symbolic summands

Edit: I attempted to use the method of repeatedly using Replace instead of ReplaceRepeated as suggested by Mr.Wizard, but the ...
110 views

### Sets of identical equality/inequalities

So I've used Mathematica for some months, but I never noticed this sort of thing about it, namely: (a > b) == (b < a) which are supposed to be identical ...
165 views

### Applying functions repeatedly on parts of complicated expressions

I am dealing with expressions like  \textrm{expr}=5D_{4,1}\langle12\rangle\langle23\rangle\big(-\langle15\rangle^2\langle24\rangle\langle34\rangle + \langle14\rangle\langle15\rangle\langle24\rangle\...
178 views

### Understanding the order of applying Rule to expression [closed]

I am a little confused about: In what order is a Rule tried to apply to an expression? In a depth-first order or otherwise? For example, ...