9 votes
Accepted

Why does this pattern not match?

The first one matches because HoldPattern just prevents the pattern from evaluation, so it is equivalent to ...
Domen's user avatar
  • 18.9k
9 votes

Apply function to all first arguments of a nested list of rules

list = {1 -> a, 2 -> {3 -> c, 4 -> d, 5 -> {6 -> f, 7 -> {8 -> h, 9 -> j}}}}; 1. MapAt ...
eldo's user avatar
  • 47.6k
8 votes

Apply function to all first arguments of a nested list of rules

Using Replace / Map : ...
Syed's user avatar
  • 41.5k
7 votes

Why does Blank sometimes not match the empty expression?

One source of confusion here is about what MatchQ[, _] actually does. Contrary to what you think, the first argument of MatchQ here is not "the empty ...
Sjoerd Smit's user avatar
  • 21.9k
6 votes

Why does Blank sometimes not match the empty expression?

Your pattern is actually interpreted as a multiplication: FullForm[_{_Symbol}] (* List[Times[Blank, Blank[Symbol]]] *) To match a list consisting of a Symbol, use ...
MarcoB's user avatar
  • 65.8k
6 votes
Accepted

Switch with string patterns

Switch doesn't use the form of the first argument to somehow predict what kind of comparison you want to do. So, it doesn't automatically try a string match just ...
lericr's user avatar
  • 24.4k
5 votes

Apply function to all first arguments of a nested list of rules

You could first find all the positions of Rule, and change the last index to 1: ...
MelaGo's user avatar
  • 7,671
5 votes

Apply function to all first arguments of a nested list of rules

the rules to get something of the form lst2={z[1]->a,z[2]->{z[3]->c,z[4]->d,z[5]->{z[6]->f,z[7]->{z[8]->h,...}}}}. how about ...
Nasser's user avatar
  • 137k
5 votes
Accepted

How to Replace 'delta t' with 'a' in Mathematica Without Affecting Separate Instances of 'delta' or 't'?

...
Bob Hanlon's user avatar
  • 151k
5 votes

Apply function to all first arguments of a nested list of rules

lst = {1 -> a, 2 -> {3 -> c, 4 -> d, 5 -> {6 -> f, 7 -> {8 -> h}}}} lst //. Rule[Except[_z, a_], b_] :> Rule[z @ a, b] {z[1] -> a, ...
kglr's user avatar
  • 384k
5 votes
Accepted

Is it possible to ask Mathematica to give/find this largest (absolute value) argument of $\cosh$ in the expression?

...
Syed's user avatar
  • 41.5k
4 votes

Pattern matching vs. condition in a function

For g4, your condition doesn't evaluate to True or False. Specifically, ...
lericr's user avatar
  • 24.4k
4 votes
Accepted

ToString[n] in pattern replace does not take the value of n

Output as String res = Power[x, 3] /. Power[x, n_] :> "xp" <> ToString[n] "xp3" Output as ...
eldo's user avatar
  • 47.6k
4 votes
Accepted

How to apply a transformation to a total derivative?

RuleDelayed (:>) doesn't hold its first argument (it only has the attribute HoldRest), so ...
xzczd's user avatar
  • 63.4k
2 votes

PiecewiseExpand fails to address assumptions

...
Bob Hanlon's user avatar
  • 151k
2 votes

Apply function to all first arguments of a nested list of rules

Additional ways to use ReplaceAll and Replace: ...
kglr's user avatar
  • 384k
1 vote

Match a sequence of integers

list = {{0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0}}; p1 = {0, 0, 1, 0, 0}; p2 = {.5, .5, 1, .5, .5}; Since V 11.3 ...
eldo's user avatar
  • 47.6k

Only top scored, non community-wiki answers of a minimum length are eligible