MathGroup Archive 1993

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

Search the Archive

Re: Variables?

Levent Kitis writes...

>Is the following a bug or is Variables[..] supposed to work this way? 

>In[1]:= p[x_] := 1 + E x + Pi x^2

>In[2]:= Variables[p[x]]

>Out[2]= {E, Pi, x}

No this is not a bug. In expression In[2], p[x] evaluates to 1 + E x + Pi
x^2. Then it returns Variables[1 + E x + Pi x^2], which is {E, Pi, x}. If
you wamted to know the variable inside the head you could define 

(* this attribute HoldAll makes sure that h[x] is not evaluated and *)
(* will match the pattern *)


In[2]:= MyVariables[p[x,y]]

Out[2]= {x,y}

In[3]:= MyVariables[p[x]]

Out[3]= {x}

hope this helps,


$ at %?$@%?$ at %?$@%?$ at %?$@%?$ at %?$@%?$ at %?$@%?$ at %?$@%?$ at %?$@%?$ at %?$@%

Jason Harris                   jfh124 at
Optical Sciences Center    
Australian National University
ACT 0200, Canberra             Tel.:  495-0191
Australia.                     Fax.:  249-5184

$ at %?$@%?$ at %?$@%?$ at %?$@%?$ at %?$@%?$ at %?$@%?$ at %?$@%?$ at %?$@%?$ at %?$@%?

  • Prev by Date: matrix manipulation using transformations
  • Next by Date: Re:FlatStrings
  • Previous by thread: matrix manipulation using transformations
  • Next by thread: Re:FlatStrings