MathGroup Archive 2007

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

Search the Archive

Cases to Select ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73920] Cases to Select ?
  • From: Mr Ajit Sen <senra99 at yahoo.co.uk>
  • Date: Sat, 3 Mar 2007 01:02:02 -0500 (EST)

 Dear MathGroup,

 Consider the following list:

  A={{1, 4, 5}, {3, -6, 1}, { 2, 0, 4}, {4, 3, 8},
{-5, 1, 4}, {3, 7, 4},{4,6,0,3}, {-3, 4, 3, 8, 1}}

 To retrieve those sublists containing 3 and 4, I'm
using

 A34C=Cases[A, {___, 4, ___, 3, ___} | {___, 3, ___,
4, ___}].

 My first query is whether there is a (neater ?) way
to combine the 2 patterns, possibly using MemberQ as
in

  A34S=Select[A, MemberQ[#, 3] && MemberQ[#, 4] &]  .


 Now, say I'd like to pick out those sublists that do
not contain 3 and 4.  Then I don't get the result
{3,-6,1} with

   NotA34S=Select[A, (FreeQ[#, 3] && FreeQ[#, 4]) &]

 nor with 
          Select[A, (FreeQ[#, 3] || FreeQ[#, 4]) &]
 nor with
          Complement[A,A34S]

 Why not?  I don't think !MemberQ exists. Looking at
all negations in the Help browser, I guess that Unsame
could do the trick but am unable to apply it.

  Finally, how could I do it using Cases

        NotA34C= Cases[A, pattern??]  ?

  Thank you very much for your help.

  Ajit Sen.

  


		
___________________________________________________________ 
Yahoo! Photos ? NEW, now offering a quality print service from just 8p a photo http://uk.photos.yahoo.com


  • Prev by Date: Re: Bug with Limit?
  • Next by Date: Re: Number of digits
  • Previous by thread: Re: Conversion to html problems
  • Next by thread: Re: Cases to Select ?