MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: New version, new bugs

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42930] Re: New version, new bugs
  • From: Maxim <.!dontsendhere at uunet.uu.net>
  • Date: Mon, 4 Aug 2003 00:45:59 -0400 (EDT)
  • References: <bggq33$or5$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com


Andrzej Kozlowski wrote:

> Maxim has pointed out that RuleCondition has the attribute HoldFirst. I
> was too careless giving my explanation: what I meant to refer to was
> the following difference between Condition and RuleCondition (which I
> learned form Allan Hayes)
>
> Hold[a] /. a :> Condition[1 + 1,True]
>
>          Hold[1+1]
>
> Hold[a] /. a :> RuleCondition[1 + 1, True]
>
>          Hold[2]
>
>

I have no idea what RuleCondition is for and how you can rewrite, say,

2/.x_:>x^2/;x>0

using RuleCondition, but it's totally irrelevant; you say that something
somewhere doesn't get evaluated -- then put Evaluate in the right place and
demonstrate the difference. I have a feeling you won't succeed. And before
you give yet another "conclusive demonstration", try also explaing how these
four examples work:

f[a] + f[b] + 1 /. HoldPattern[Plus][_, _] /; True :> 1
f[a] + f[b] + 1 /. HoldPattern[Plus[_, _]] /; True :> 1
f[a] + f[b] + 1 /. HoldPattern[Plus][_, _] :> 1 /; True
f[a] + f[b] + 1 /. HoldPattern[Plus[_, _]] :> 1 /; True

I'll try giving a suggestion why the four examples in my original posting
(with f[_]..) work that way; it is probably related to the following:

In[1]:=
FreeQ[x+y+z,x+y]
Cases[x+y+z,x+y,{0,-1}]

Out[1]=
False

Out[2]=
{}

Even though Cases does pattern matching (the second argument can be a
pattern), in this case it doesn't break the expression into Plus[Plus[x,y],z]
(yes, I know that it is a documented feature). So my guess is that somewhere
in the dark recesses of Mathematica pattern matcher this confusion between
two approaches arises.

Of course, maybe Jens-Peer Kuska will explain to me again how I don't know
what I'm doing, but he did seem to be rather quiet lately...

The real problem is that there isn't any complete specifications describing
the behaviour of pattern matching. So it's not even possible to say if an
example is correct/incorrect, one has to resort to simply pointing out
inconsistencies...only it seems that developers sometimes have to resort to
the same means.

Exactly the same goes for the example with Module and variables renaming.

Maxim Rytin
m.r at prontomail.com



  • Prev by Date: Re: Re: PDE
  • Next by Date: OOP in Mathematica
  • Previous by thread: Re: Re: Re: Re: New version, new bugs
  • Next by thread: Re: Re: New version, new bugs