Re: few easy questions (HoldPattern)
- To: mathgroup@smc.vnet.net
- Subject: [mg11527] Re: few easy questions (HoldPattern)
- From: Paul Abbott <paul@physics.uwa.edu.au>
- Date: Fri, 13 Mar 1998 12:22:16 -0500
- Organization: University of Western Australia
- 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} Because Dt[x_] is evaluated _before_ the pattern-matching occurs. You can get around this using HoldPattern: In[10]:= {Dt[a], Sin[a]} //. {HoldPattern[Dt[x_]]:> 1, Sin[x_] :> 1} Out[10]= {1,1} Cheers, Paul ____________________________________________________________________ Paul Abbott Phone: +61-8-9380-2734 Department of Physics Fax: +61-8-9380-1014 The University of Western Australia Nedlands WA 6907 mailto:paul@physics.uwa.edu.au AUSTRALIA http://www.pd.uwa.edu.au/~paul God IS a weakly left-handed dice player ____________________________________________________________________