MathGroup Archive 1998

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

Search the Archive

Re: few easy questions



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




  • Prev by Date: Re: Introducing: Conix 3D Explorer!
  • Next by Date: Re: Eigenvalues
  • Prev by thread: Re: few easy questions
  • Next by thread: Flat riddle