Re: possible bug in Cases/pattern matching??
- To: mathgroup at smc.vnet.net
- Subject: [mg6953] Re: [mg6859] possible bug in Cases/pattern matching??
- From: Elaine Kant <kant at scicomp.com>
- Date: Wed, 30 Apr 1997 22:25:04 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Here is the ultimate solution to my problem of the apparently-off-in-
hyperspace behavior of Mathematica on longish expression (test):
test /. xx_ + num_Real :> xx+mcDouble[num]
Using the following rule instead of the above rule gives a quick check
for any matches and a less combinatorially-intense matching routine:
test /. p_Plus :>
With[{result = Replace[p, (xx_) + (num_Real) :> xx + mcDouble[num]]},
result /; result =!= p] /; MemberQ[Head /@ Apply[List, p], Real]
Thanks to David Withoff for the solution, and to him and Michael Trott
for explanation of why it was taking so long and general suggestions of
possible work arounds. Thanks also to Richard Gross who has more patience
that me, and maybe a bigger and faster machine, who demonstrated that if
I had waited long enough I might have gotten an answer:
In[5]:= Cases[tester, xx_ + num_Real, Infinity]//Timing
Out[5]= {8424.35, {}}
-- Elaine
====================================
Elaine Kant
SciComp Inc.
5806 Mesa Drive, Suite 250
Austin, TX 78731
email: kant at scicomp.com
voice: 512-451-1430
fax: 512-451-1622
www: http://www.sig.net/~scicomp/