# pattern-matching's questions - English 1answer

922 pattern-matching questions.

### 1 ReplaceAll does nothing with the rgb values of a picture

0 answers, 26 views pattern-matching replacement image
In the book "Programming with Mathematica: An Introduction" at the beginning of the chapter on Patterns and rules an example is given where the colors of an image are transformed according to ...

### 26 Is there a GraphicsPrimitiveQ (or a complete list of Heads of graphics primitives)?

For various reasons related to workflow associated with creating figures for journals, I am creating functions that will accept graphics primitives and a set of options and spit out a ...

### 9 About shorthand notation for conditional pattern (Paul Wellin “Essentials of Programming in Mathematica”)

2 answers, 279 views pattern-matching expression-test
I am reading Paul Wellin's "Essentials of Programming in Mathematica". Mr. Wellin wrote the following in his book: There is a convenient shorthand notation for conditional patterns that is ...

### 6 Identifying Infinity, Indeterminate, etc

I am doing a calculation and sometimes in the middle of the calculation a parameter evaluates to the following ...

### 1 Why does ReplaceAll match pattern while MatchQ fails

1 answers, 29 views pattern-matching replacement
Why does the following pattern with MatchQ failMatchQ[1+Sin[1] I, a_Complex /; Im[a] > 0] (* False *)Whereas, the same ...

### Simplify by defining new functions

if I have a formula like ...

### Replacing one of the integrals in the multiple integral with an analytical solution

Problem consist in simplifying complicated multiple numerical integral, where I know analytical solution for a subset of them. Integrand is of the form ...

### 4 Subtle order-of-evaluation issues when pattern-matching with attributes

1 answers, 57 views evaluation pattern-matching attributes
Related question concerning unrolling the tests that are shown below: Big and Little surprises when unrolling tests of pattern-matching and attributes Questions researched before posting this one: ...

### 3 Big and Little surprises when unrolling tests of pattern-matching and attributes

1 answers, 61 views pattern-matching attributes
Related question concerning interpretation of the substitutions: Subtle order-of-evaluation issues when pattern-matching with attributes Questions researched before posting this one: Orderless ...

### 1 Pattern transformation to implement “factoring out”

I'm attempting to put together some code that would do pattern based expression manipulation (I know it's already implemented in mathematica), but I'm getting stuck on a pattern to deal with "...

### 3 Match Polish letters

I am quite confused about the following cases, in Mathematica 9.0.1.0: LetterQ["ł"] StringMatchQ["ł", WordCharacter ..]The first case gives ...

### 7 Finding items satisfying a condition in a list using patterns

3 answers, 170 views pattern-matching filtering
Why the following commandCases[{1, 2, 6, 3, 4, 8, 5}, {x_, y_, z_} /; (y > Max[x, z]):>y]doesn't return the y values that are greater than their ...

### 4 Repeated replacing elements in the list

3 answers, 85 views pattern-matching replacement
I have a large list of the following form{{1, 2} -> -1, {1, 1} -> 1, {1, 2} -> -1, {1, 6} -> 1}and I want to combine all of the pairs ...

### 1 Create mirror function using pattern matching

I want to implement pattern matching for a few simple types. In particular, I want to define a function mirror that mirrors circles and rectangles. That is, ...

### 5 default value for the 2nd argument in Power for pattern matching

I'm trying to match terms in power like a^b, including b=1 case. I know that I can do something like ...

### 1 Apply operator to certain functions

I have the following term a[om1] b[om2] c[om3] d[om4] f1[om1] f2[om2] f3[om3] f4[om4] I want to apply an operator ...

### : versus :=

1 answers, 69 views pattern-matching documentation
I am going through the Fast introduction for programmers tutorial on Mathematica. The page on patterns has the below line: x_ (short for x:_) stands for a pattern whose value will be named x ...

### 3 Isolate first order elements

How can I isolate only the first order "h" terms in the following expression? ...

### 8 Recursion depth exceeded in pattern matching with attribute Flat

I am defining a linear associative multiplication operation Mult[]: ...

### 1 Working of MatchQ[] with Blank, BlankSequence, BlankNullSequence [closed]

1 answers, 63 views pattern-matching debugging
This code:In[76]:= Trace[MatchQ[{1,2,3}, {_?NumberQ}]]gives: Out[76]= {MatchQ[{1,2,3},{_?NumberQ}],False} This code: ...

### 3 How can I replace non-reals in a multidimensional list?

Ok. I'm obviously not understanding something about pattern matching. I have a list called t like the following: ...

### 8 Delete all strings that are prefixes of another string

I have a long list of strings and I'm trying to find a more efficient way of removing those elements that are prefixes of another: ...

### 2 Construct a function like Coefficient

I'am trying to construct a function that will work like Coefficient as an exercise. ...

### 8 Why does MatchQ[a, r_ /; Head[r] != Plus] evaluate to False?

I'm trying to understand. Why is it that:MatchQ[a, r_ /; Head[r] != Plus]Evaluates to:False? For me, I would think ...

### 26 Version inconsistency with optional arguments: what if the default value doesn't match the pattern?

I just came across some weird behaviour. Take this function definition:ClearAll[f] f[vs_List : All] := "match"The default value of ...

### 3 Replacement rule to display negative exponents as denominators

Suppose I have an expression of the form:expr=f[t]^b + f[t]^a g[t]^-a + g[t]^-cAnd I want to create a rule to convert negative exponents to denominators. In ...

### 9 Optional pattern behaves differently in version 8, 9, and 10+

We recently ran into an issue when testing Rubi on older versions. It boils down to this simple example which I didn't dare to simplify further as I cannot test it in versions < 10 ...

### 2 Why _Line works in this Cases as pattern?

1 answers, 57 views functions pattern-matching
I got this from examples, and it works, but I can not understand it first the initial dataf1[x_] := 4 x^3 + 0.1 x^2 - 7 x - 1 pss = Plot[f1[x], {x, -1.3, 1.53}]...

### 4 Change matrix elements at specific locations?

Let's say I have an arraya={{1,2,3}, {4,5,6}, {7,8,9}}I want to have all elements along the diagonal multiplied by 2. ...

### 4 Create pattern condition dynamically

Suppose i have a functioncondition[pattern_,list_]:=With[ {x=Unique["x"]}, Condition[Pattern[Evaluate[x],pattern],Not@StringContainsQ[x,list]] ];If i ...