pattern-matching's questions - English 1answer

889 pattern-matching questions.

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

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

I have to set the first and last rows and columns to zero rows and columns. I tried with the first column: ...

(Oddly enough, the title for another question that ended up dealing with an unrelated problem could have worked better here, but I didn't want to plagiarize.) Given a symbolic vector function ...

I have a piecewise function defined with vectors, e.g.ab = Piecewise[{ {{a1, a2, a3}, 0 < r < 1}, {{b1, b2, b3}, 1 < r < 2} }, {c1, c2, c3}]The ...

Suppose we have a function f with the Attribute Flat. From my understanding, the following command should return all possible ways of rewriting ...

I'm looking to test whether a string contains all substrings in it, independent of each substrings location. For example: ...

Suppose a want a pattern to match:-1 -1. -1.`42 (or any other value for the precision)with a pattern. What would be the best pattern to use? I guess one could ...

I want to apply the following rulem^p_ :> (m^p - Log[n]^p)to m^x where x may be one. ...

This is a rewording of the question. The original post is below. How come that a pattern for an expression with a specific head is not more specific than a pattern for an expression with a generic ...

Extract the qualifying sublists. – Condition: The elements are all in the Reals and greater than zero. Question If the sublist contains many elements, how can it ...

I'm stuck in a seemingly easy question, but I can't figure out why the GreaterThan function and the pattern test do not work. I have tried to debug it for a while, ...

I get what I expect from the following codeReplace[{a, b, c}, b_ -> (w /; x > b), {1}] (* {w /; x > a, w /; x > b, w /; x > c} *)However, when I ...

I want to parse a Mathematica Notebook to get some information regarding the relative use of symbols. So first things first: ...

I have read in a Mathematica notebook and have assigned its content to the variable file. I have created the Strings corresponding to Wolfram Language symbols as ...

How to implement a commutator of matrices composed of operators? Background: Let $\hat A_{ij}$, $\hat B_{kl}$ be some sets of some operators. $\hat I$ is the identity operator. Their commutators are ...

I have imported a Mathematica Notebook and assigned it to the variable file. In addition, I have gathered the strings corresponding to all Wolfram Language symbols:...

After reading this post I recalled an old question I once met. We know that we can set default values for variables of a function: ...

Suppose we have the following expressionA[j_] := Subscript[A, j] EXPR=A[1]^2*A[2] + A[1]^4*A[3] + A[2]^2As stated in the title, I am struggling to retain some ...

Based on help that I got from rhermans here, I wrote a module to download financial data, format it and export it to Excel. ...

Consider thisf[x_Real] := 2 xf[1] f[1]f[1.0] 2.0 I want ...

I am trying to reproduce the example of Data Cleaning from here. I had to make a slight change in input 13 to ...

Suppose I have a string like "a-1_b-2_c-3_d-4" with numbers, labels, and separators, and I want to get ...

If I have a list:list:={{1,1}, {2,2}, {3,3}, {4,"a"}}And I would like to delete the row with a string character, the following works: ...

Given a list, how to get all possible new lists replacing a matched pattern with a new pattern (every time only one replacement)? For example, I have a list like this ...

Consider I have a list l ...

My question is quite a simple one, but I have not been able to find a solution yet. Say I have terms of the form e.g1/n1/n2/n3/n4and ...

Bug introduced in 9.0 or earlier, partially fixed in 10.1 and persisting through 11.3 [CASE: 4075992] confirmed Note: See (72290) for the fixed part of the bug. Consider the following example:<...

Bug fixed in 10.1 Consider the following pattern-matching expressions: ...

I would like, as an example, to build a Times-like function. Take the following example ...

By default, an expression like NoncommutativeMultiply[x] does not simplify to x, unlike ...

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

May be that I did not understand something about Mathematica pattern matching, but I noticed what follow:st is a string, inside the string there is a date (...

I'm having problems setting an upvalue for a symbol that is supposed to ignore Inactive:IgnoringInactive[f[g[x]]] ^:= match;...

I have had a look through the documentation and I cannot find a ProbabilityDistributionQ function. How can I return True if the ...

I am finding the minima of a 2D cubic periodic function by "brute force", i.e. looking for the (x,y) positions where the both the x and y derivatives are 0. This returns a list of points, in this ...

I need to make a GeoGraphics[] object then save it to disk, move it to another computer where I need to load in the object then add some more ...

I have the following simple code:z = {a, b, c} {{1, 2, 3}, {1, 3, 2}, {3, 2, 1}} /. {a_Integer, b_Integer, c_Integer} /; OrderedQ[z] -> 1which returns ...

This is a slight variation of: How to generate all possible orderless partitions of a list according to another list? Consider each set following a partition a "box" and each element a "ball". What ...

This is a very simple question. I have an unnamed pattern and a test function should determine whether to perform replacement on it. How to make the following piece of code to work: ...

I have a list of reals and I want to check if for every element $i$ there is another element $j$ such that $\lvert{i-j}\rvert \leq x$ where $x$ is some arbitrary value. Each element can only be "...

I would like a pattern which takes as an argument a set with $n$ elements, and an integer $k$ which is less than $n$ and greater than 1, and which matches against any $k$ distinct elements of the set, ...

In my Mathematica 11.3.MatchQ[-3*i[1], -x_*i[1]]returns False. ButMatchQ[-3*i[1], x_*i[1]]returns True. I don't ...

I'd like a pattern which matches an expansion of a vector in a given basis, so mathematically any expression of the form $\mathbf{v} = \sum_{i = 1}^n v_n \mathbf{a}_n$. The basis is defined by a ...

Suppose, I have an expression like so:In[68]:= expr = 2 + 5*q + q^2 + 8 q^3 + 19 q^7 Out[68]= 2 + 5 q + q^2 + 8 q^3 + 19 q^7Now I want to take all powers of q ...

Bug introduced in 10.4.0 and persisting through 11.3.0 CASE:3824590 [...] Developers are discussing this behavior. [...] I will let you know when I have definite information on this. [...] ...

Related tags

Hot questions

Language

Popular Tags