Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 97982

Questions on expression testing and manipulation through pattern matching and constructing efficient patterns.

3 votes
2 answers
45 views

Trouble with replacement rules for squared variables [duplicate]

I want to do replacement of products (because I am dealing with abstract projectors), but Mathematica seems to fail understanding this toy example replacement : x y y /. {x y -> 1} x y^2 because it …
Adrien Martina's user avatar
5 votes
2 answers
189 views

Pattern recognition for products of variables

Pattern recognition doesn't work as I would expect when trying to match products, for example Cases[a[1] b[1] a[2] b[2], x___ a[k_] b[k_] -> k, All] {1} Cases[a[1] b[1] a[2] b[2], a[k_] b[k_] -> k, …
Adrien Martina's user avatar
4 votes
5 answers
247 views

How to make expression-dependent replacements?

Consider as a toy example that I want a replacement which acts on {x,1,2,3} by replacing $x$ with the length of the list itself. In this example this should output {4,1,2,3} So I want a code that l …
Adrien Martina's user avatar
5 votes
3 answers
384 views

Reversing the order of function arguments by a replacement rule

I am facing an issue when I try to reverse the arguments of a function in a replacement rule. Let me give an example : g[x3, x2, x1] /. {g[arg___] -> g[Sequence @@ Reverse[{arg}]]} This outputs g[x3 …
Adrien Martina's user avatar
3 votes
1 answer
72 views

Troubles with BlankNullSequence in the case of multiplication

I have some trouble to use the triple underscore notation to use definitions with or without a term. Consider the following toy example f[a___ x]:=1 {f[x],f[2x]} This returns {f[x],1} whereas I wou …
Adrien Martina's user avatar