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

learn more… | top users | synonyms (1)

1
vote
1answer
47 views

How can I get the functionality of a command ReplaceAllList?

I'm trying to use ReplaceList to match subexpressions. I expected the command: ReplaceList[{p, {p, p}}, {x_, y_} -> x y] to output two results, equivalent to: ...
26
votes
0answers
357 views

Why is StringExpression faster than RegularExpression?

Edit: as noted by Albert Retey the performance difference is only seen when sub expression extraction is performed. If this test is used below the timings are similar: ...
25
votes
0answers
474 views

How is pattern specificity decided?

Mathematica has a notion of pattern specificity, which is a partial ordering on patterns. The rules (e.g. DownValues, ...
5
votes
0answers
164 views

Convert logical relational expression to / from disjunctive and conjunctive forms?

I would like to convert logical relational expressions in disjunctive form, e.g., $$(x \lt -1) \lor (-1 \lt x \lt +1) \lor (x \gt +1)$$ into conjunctive form, e.g., $$(x \ne -1) \land (x \ne +1)$$ ...
4
votes
0answers
105 views

Syntax error for optional pattern, but only in debugger

This expression (explained here by Leonid) evaluates fine unless Evaluation->Debugger is enabled: h[x : (_Integer) : 1] := x Syntax::sntxf: "x:" cannot be ...
3
votes
0answers
128 views

I am missing a function like HoldPattern

Temporary message: I am planning to edit this question, making the examples less confusing and by moving the things that are confusing to a separate question For any confusion about expressions that ...
2
votes
0answers
150 views

NDSolve Issue with initial conditions

I am trying to implement a Poincare section for a gravitational movement on the plane $(x,y)$. Here is the code I wrote ...
1
vote
0answers
43 views

Function behavior based on Head

I'm figuring how to implement a function behavior based on the Head of its argument. I mean ...
1
vote
0answers
33 views

Matching Root[…] objects with patterns, unexpected hidden argument

I needed to write patterns that could distinguish between arbitrary-function and polynomial forms of Root objects, for example, ...
0
votes
0answers
42 views

How can I represent this automorphism of Q(i,a)?

Let $a$ represent some real irrational number. I am trying to perform computations with an automorphism $f:\mathbb{Q}(i,a)\to\mathbb{Q}(i,a)$ which fixes $\mathbb{Q}(i)$ pointwise and maps $a$ to $i ...
0
votes
0answers
61 views

Pattern in Element[x,Arrays[…]]

I want to define a "prefix" (D_i) covariant derivative operator CD[] for symbolic tensors in form of a function, i.e. for ...