MathGroup Archive 2011

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

Search the Archive

Re: what's wrong?!!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115660] Re: what's wrong?!!
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Tue, 18 Jan 2011 05:46:05 -0500 (EST)

On 17 Jan 2011, at 11:40, olfa wrote:

> Hi Mathematica community,
>
> I try to use Case[exp,patt,Infinity]
>
> for the first example it works:
> Cases[iP == i + v && kaP == 3^v,  iP == _ | kaP == _, Infinity]
> the output is  {iP == i + v, kaP == 3^v}
>
> but not for the second one!!
> Cases[yP == y + x - z, yP == _, Infinity]
> the output is  {}
>
> why?!!
>
> Thank you.
>

Because using the level specification Infinity means that you want to find patterns on levels from 1 to Infinity but the pattern you are trying to find is on level 0. So this will work in all your cases:

Cases[yP == y + x - z, yP == _, {0, Infinity}]

{yP == x + y - z}

(More precisely, in your first example the patterns you want are on level 1:

Cases[iP == i + v && kaP == 3^v, iP == _ | kaP == _, {1}]

{iP == i + v, kaP == 3^v}

but in the second they are on level 0:

Cases[yP == y + x - z, yP == _, {0}]

{yP == x + y - z})

Andrzej Kozlowski


  • Prev by Date: Re: what's wrong?!!
  • Next by Date: Re: what's wrong?!!
  • Previous by thread: Re: what's wrong?!!
  • Next by thread: Re: what's wrong?!!