|
[Date Index]
[Thread Index]
[Author Index]
Re: Replacement Rule with Sqrt in denominator. Also Bug in Series; see Semantica / Harris solution
- To: mathgroup at smc.vnet.net
- Subject: [mg114638] Re: Replacement Rule with Sqrt in denominator. Also Bug in Series; see Semantica / Harris solution
- From: Richard Fateman <fateman at cs.berkeley.edu>
- Date: Sat, 11 Dec 2010 01:54:08 -0500 (EST)
I just came across this, from a link in this newsgroup, 10 years ago or so.
Jason Harris wrote a package called "Semantica" for pattern matching.
It rewrites ReplaceAll etc etc etc, and adds a functionality by
producing new rules if the LHS includes "Semantic" parts. Thus
f[8] /. f[Semantic[2*x_]] -> g[x]
returns g[4].
f[3+4 I] /. f[Semantic[a_+b_ I] -> aha[a,b]
returns aha[3,4]
.. actually, it doesn't quite do that in version 7.0, but
it almost does. I don't know if the bug would be exhibited in
the version of Mathematica current in 1999. It seems to involve
a disagreement about dynamic binding.
Harris' code requires the use of Solve when defining rules,
but often need not use Solve when applying them.
See
http://www.mathematica-journal.com/issue/v7i3/features/harris/
For your information, the first of the rules above, f[Semantic[2*x_]]->g[x]
is converted to
{HoldPattern[f[L$10_]] :> With[{x = L$10/2}, g[x] /; True]}
There are various limitations in the rule transformations, like only
single-underscore variables are allowed.
Actually, it doesn't handle the rule Sqrt[x] -> g.
but maybe that could be added. Perhaps it could become
x^(r_) :> With[{L = 2*r}, g^L /; Denominator[r] == 2]
Harris' code looks fairly complicated, but can be downloaded free.
Not like the paper, which appeared in the "Mathematica Journal".
I guess Jason Harris is doing something else now.
RJF
Prev by Date:
Re: ErrorListPlot
Next by Date:
Re: Puzzled by IntegerPart
Previous by thread:
Re: Question: Compile in Mathematica 8.0
Next by thread:
Re: Replacement Rule with Sqrt in denominator. Also Bug in Series; see Semantica / Harris solution
|