MathGroup Archive 2003

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

Search the Archive

Re: extracting variables from an expression

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44134] Re: extracting variables from an expression
  • From: Tom Burton <tburton at brahea.com>
  • Date: Fri, 24 Oct 2003 04:24:04 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 10/23/03 1:31 AM, in article bn8e5q$ngu$1 at smc.vnet.net, "Peter Schinko"
<Peter.Schinko at utanet.at> wrote:

> Hi,
> 
> I'm looking for a function that extracts all variables from a boolean
> expression.
> For example:
> x || y || z
> should return something similar to {x, y, z}.
> 
> Is there a similar function in Mathematica? If so, how does it work?
> 
> Thanks very much
> Peter

You might try something like this:

Cases[HoldForm[x || y || z], _Symbol, {0,Infinity}]

HoldForm prevents evaluation of the expression. {0,Infinity} searches at all
levels. (By default, Cases will allow the first argument to evaluate and
then search only the first level of the evaluated expression.) Neither
addition may be needed in this example, but I think they are good practice.

Tom Burton


  • Prev by Date: Re: extracting variables from an expression
  • Next by Date: Re: Det in TraditionalForm
  • Previous by thread: Re: extracting variables from an expression
  • Next by thread: Re: extracting variables from an expression