Linked Questions

15
votes
4answers
898 views

How to replace the first occurence in an expression instead of replacing all?

Is there a function that replaces the first occurence of the expression instead of replacing all? For example, if I have HoldForm[x + 2 + 4 + x] /. x -> 4, is ...
12
votes
4answers
339 views

Evaluation of Alternatives

I recently stumbled upon a few examples that suggest patterns containing Alternatives do not evaluate for individual alternatives. For example: ...
22
votes
2answers
432 views

Pattern does not match with Orderless head

Why does the following pattern matching not succeed? ...
10
votes
3answers
448 views

Matching (y/x)^u terms wherever the appear in an expression

Mathematica keeps rewriting expressions, so it is hard to figure what pattern to use. I am trying to replace all occurrences of $\frac{y}{x}$ by $t$, but Mathematica re-writes $\frac{1}{\left(\frac{y}...
7
votes
2answers
470 views

Using MatchQ (or other means) to parse an expression using sums of COS or SIN correctly

I am writing a function that will take an expression as input. I want to make sure the expression is valid first before processing it. Looking for a correct to use ...
3
votes
2answers
444 views

Extracting argument sequences from function expressions

Why is it that fun[x, y] /. fun[z__] :> z leads to Sequence[x,y] but ...
10
votes
1answer
214 views

FullForm of b/c and c/b with different order

I am studying Mathematica myself and doing some exercises for improvement. Question: Try to guess the internal forms of b/c and ...
3
votes
1answer
106 views

Apply functions to a BlankNullSequence

I'd need to apply all functions in a list to a BlankNullSequence (___) But when I tried ...
5
votes
2answers
100 views

MatchQ failing in some cases with Hold [duplicate]

Could someone clarify why the first of these MatchQ finds a match whereas the second does not? (I'm using version 10.0, in case that matters.) ...
4
votes
1answer
164 views

FreeQ and arguments of Hypergeometric2F1

I was trying to use FreeQ to test for the presence of Hypergeometric2F1 functions in my expressions. I encountered the following ...
0
votes
0answers
39 views

Problem with replacing a head with another head using pattern [duplicate]

Why would this work Times[a, b, c, d] /. Times :> List (* {a, b, c, d} *) but this doesn't work (the Times still remains ...