# Tag Info

### How to define replacement rule for Minkowski inner product

Mi = DiagonalMatrix[{1,-1,-1,-1}] Dotp[{qm[0], qm[1], qm[2], qm[3]}, {qn[0], qn[1], qn[2], qn[3]}] /. Dotp[t1_List, t2_List] :> (t1.Mi.t2) Or ...
• 31.2k

### How to define replacement rule for Minkowski inner product

Dotp[{qm[0], qm[1], qm[2], qm[3]}, {qn[0], qn[1], qn[2], qn[3]}] /. Dotp[a_List, b_List] :> Fold[#1 - #2 &, a b] qm[0] qn[0] - qm[1] qn[1] - qm[2] qn[2] -...
• 19.3k

...
• 116k
Accepted

### Deleting list of expression by rules

You can use FreeQ to check for the existence of z in any of the expressions and filter using ...
• 27.1k
Accepted

### Replace vs. ReplaceAll involving Flat

For a way to explain the behavior, see @MichalE2's answer The following might be a workaround, at least for the examples in the question. It is based on the observation that a catch-all rule like <...
• 27.1k

### Replace vs. ReplaceAll involving Flat

why does Replace not try the pattern f[f[x, 2y], z]? First, I don't think ReplaceAll does ...
• 222k
Accepted

### Transforming A Complicated Expression

I don't think this is well-suited for replacement rules, since, among other things, you will have a hard time restricting the rules to only apply to entire terms (i.e. not stuff like the ...
• 27.1k
Accepted

$Version (* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" *) In a PatternTest the test must be a boolean ... • 126k 5 votes Accepted ### Equivalent of Nothing for patterns You could use Repeated[..., {0,1}] to match elements which may appear zero or one times, but there's even better option in this case, that is, ... • 15.6k 3 votes ### Equivalent of Nothing for patterns The comment section got a bit long and as it would be tedious for someone else to read through the comments I moved my last comment, that only solves this specific situation, to an answer. I had never ... • 1,373 2 votes ### Extracting values from association via Cases Let's say temp had a string value in there as well: temp = <|"u" -> -5, "v" -> -5, "w" -> "a"|> -> -30 In ... • 19.3k 4 votes Accepted ### Extracting values from association via Cases According the the Docs for Cases, The default value for levelspec in Cases is {1}. You ... • 60.3k 5 votes ### How to group or factor out exponential terms of an integral result ... • 19.3k 4 votes Accepted ### Translate selection from one list to another Using PositionIndex and GroupBy: ... • 5,562 1 vote ### Clarification of the$MemberQ\$

Note that there must be a space between the dot and the "1". If one copies your input, the space disappears. Then note that "MemberQ[expression,element]" without any level ...
• 29.6k

### Translate selection from one list to another

The most minimal way -I think- to pick the even elements is to use the step specification in the Part like so: list = {a, b, c, d, e, f}; list[[2 ;; -1 ;; 2]] <...
• 6,579

### Translate selection from one list to another

Or use Association. ...
• 41.8k

### Translate selection from one list to another

You could use Pick[]: Pick[{a, b, c, d, e, f}, EvenQ[{1, 2, 3, 4, 5, 6}]] (* {b, d, f} *) Timing examples (numerical methods ...
• 222k

### Translate selection from one list to another

There can be many solutions, and here is one of them. ...
• 19.3k
1 vote
Accepted

### Replacing a term according to a given criterion in an expression with non-commutative multiplication (for any sign and location)

For the examples b ** (-P ** a^3) + b ** Transpose[-P ** a^3] b ** (-P ** J ** a^3) + b ** Transpose[-P ** (-J) ** a^3] you can try ...
• 667