MathGroup Archive 1999

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

Search the Archive

Re: Variables[] in general expressions


Ken,

This may not be what you want, but maybe it's close:

AllVariables[expr_] := Cases[expr, _Symbol, Infinity]

In[6]:=
AllVariables[y + Exp[x]]
AllVariables[y + f[x + 1]]

Out[6]=
{E, x, y}

Out[7]=
{y, x}

Carl Woll
Physics Dept
U of Washington

Ken Rice wrote:

> Hi there,
>
> Is there any way of extracting a list of variables from a general
> expression, not just a polynomial? I want something which will do,
> e.g.
>
> In      AllVariables[y + Exp[x]]
> Out     {y,x}
>
> Apologies if I'm just being dim.
>
> Ken Rice
> _____________________________________________________
> Kenneth Rice
> Churchill College
> Cambridge
> CB3 0DS, UK
> E-mail: kmr1004 at cam.ac.uk



  • Prev by Date: Re: fractions as axes-labels?
  • Next by Date: Re: Contourline values
  • Previous by thread: Variables[] in general expressions
  • Next by thread: RE: Variables[] in general expressions