Re: few easy questions
- To: mathgroup@smc.vnet.net
- Subject: [mg11544] Re: few easy questions
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Sat, 14 Mar 1998 13:55:59 -0500
- References: <6e85du$ngs@smc.vnet.net>
Arturas Acus wrote: > Why this two substitutions act differently In[9]:= > {Dt[a], Sin[a]} //. {Dt[x_] :> 1, Sin[x_] :> 1} Out[9]= > {Dt[a], 1} Arturas: The result In[1]:= Dt[a]/.Dt[x_] :> 1 Out[1]= Dt[a] is because Dt[x__] evaluates before the replacement is tried and gives In[2]:= Dt[x__] Out[2]= (1,0) Dt[x] Pattern [x, __] which is not matched by Dt[a]. This is because we have In[3]:= FullForm[x_] Out[3]//FullForm= Pattern[x, Blank[]] which behaves in the same way as p[x,b[]] when Dt is used: In[4]:= Dt[p[x,b[]]] Out[4]= (1,0) Dt[x] p [x, b[]] We can prevent this evaluation, without interfering with matching, by using HoldPattern: In[5]:= Dt[a]/.HoldPattern[Dt[x_]] :> 1 Out[5]= 1 -- Allan Hayes Training and Consulting Leicester, UK hay@haystack.demon.co.uk http://www.haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44 (0)116 271 8642