pattern-matching's questions - English 1answer

922 pattern-matching questions.

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 ...

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 ...

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 ...

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

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

if I have a formula like ...

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

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: ...

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

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 "...

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

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 ...

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 ...

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

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

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 ...

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 ...

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

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

This code:In[76]:= Trace[MatchQ[{1,2,3}, {_?NumberQ}]]gives: Out[76]= {MatchQ[{1,2,3},{_?NumberQ}],False} This code: ...

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

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: ...

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

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

I want to generate a list of $L$ and $S$ according to the following rule: upon each iteration, replace $S \rightarrow L$ $L \rightarrow LS$ Such that, starting with $L$: $ L \rightarrow LS \...

I have a list a = {L, S, L, L, S} and I can find the position of of either L or S by: ...

Here is a quick one, hopefully. I searched through different tutorials and documentation articles but haven't been able to find anything yet. What does _. mean? As ...

I would like to select the term Subscript[Cos\[CapitalDelta], Subscript[p, B]] of expression ...

In the following, why does N not produce the expected decimal output, while Round does? ...

This expression is taken from a talk given by the late Robby Villegas. The UpValues to some symbol a is defined below as: ...

Is there a clean way to match patterns that combine general patterns and ?StringExpressionFor example, Cases will not match ...

I am trying to define a replacement rule for an arbitrary sum of terms in an equation, that returns the x[i] terms along with their coefficients. For example, ...

The input x^2 + x^3 /. x^i_ -> iyields: 5 The inputu = {1, 2, 3} x^2 + x^3 /. x^i_ -> u[[i]]still yields the ...

I have a list of integers:s = {4, 5, 5, 6, 2, 5, 3, 2, 4, 2, 1, 1, 4, 3, 4, 3, 1, 6, 3, 4};And if I do this, both occurrences of 4 after 3 are replaced. ...

I would like to create a list of arbitrary length:{x1_, x2_, ...}Where each of the elements of the list has the full form: ...

As a newbie, I've got a rather simple question. I would like to define a function that accepts one of a few possible strings. I.e., I wish to do the following. ...

I am looking for help in writing transformation rules in which I wish to distinguish between eight variables $x,x^2,\bar{x},\bar{x}^2, x_p,x_p^2, \bar{x}_p,\bar{x}^2_p $. For each of these eight ...

Why does Cases[] output an element only in the first of the following lines? ...

Consider this list of rulesrules = {a -> 1, b -> 2, c -> 3}I'd like to fish some of the rules out of such a list using ...

I'm trying to define a pattern that will match lists of lists, where the inner lists contains only numbers (I want the sum of each list). Like this ...

I need a pattern for a string that does not contain a specified string, while at the same time respecting the mandate to match only shortest sequences. For example strings bracketed by ...

I have an expression with each term therein either containing at least one $n_i \in \left\{ n_1 , n_2 \dots , n_{5} \right\}$ or no $n_i$ at all. I would like to easily eliminate all the terms that ...

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

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 ...

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 ...

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}]...

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. ...

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

RuleDelayed gives different results when list length is 3 than the results given when list length is 1 ,2 or 4. ...

Imagine, as a simple toy example, that it's valid to replace some list with any one of its elements. How could I write this into Simplify ...

Related tags

Hot questions

Language

Popular Tags