Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Cases

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50459] Re: Cases
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Sat, 4 Sep 2004 01:43:55 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 9/3/04 at 3:35 AM, jerry.blimbaum at navy.mil (Blimbaum, Jerry AA
R22) wrote:

>Given:   x = {a,b,c,d,d};

>Applying   Cases[x,d]   gives an output of {a,b,c}......

I assume you really meant Cases[x,d] gives an output of {d,d} since that is what it is documented to to and does on my system.

>However, Cases[x,Not[d]] gives as output an empty list  { }... I
>expected   {a,b,c}.....

>Why didnt I get that?

Because none of the elements of your list x have a Head of Not.

Cases returns all of the elements that match the specified pattern. When none of the elements have the same head as the specified pattern, Cases correctly returns an empty list.

If you want to output a list of everything in the list different from a specified pattern, use DeleteCases, i.e.,

DeleteCases[x, d]
{a, b, c}

And note

x==DeleteCases[x,Not[d]]
True

since there is no matching element to Not[d]
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: definite and indefinite Integrate
  • Next by Date: Re: Cases
  • Previous by thread: Re: Cases
  • Next by thread: Re: Cases