Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Lists: how to?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110022] Re: Lists: how to?
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sat, 29 May 2010 04:45:09 -0400 (EDT)

On 5/28/10 at 7:21 AM, stevebg at ROADRUNNER.COM (S. B. Gray) wrote:

>I have this line

>subs3 = Subsets[Range[numbr], {3}] which for numbr=7 gives subs3=

<output snipped>

>Given one of these sublists, say {1,4,5}, I want a nice way to
>delete all members of the subs3 list which have 1,4, or 5 in any one
>of the three positions. The reduced list in this example would be
>{{2,3,6}, {2,3,7}, {2,6,7}, {3,6,7}}.

>The way I'm doing it runs DeleteCases nine times. Is there a better
>way?

Here is one way

In[12]:= DeleteCases[subs3, _?(Intersection[{1, 4, 5}, #] != {} &)]

Out[12]= {{2, 3, 6}, {2, 3, 7}, {2, 6, 7}, {3, 6, 7}}



  • Prev by Date: Graphics questions
  • Next by Date: Re: Lists: how to?
  • Previous by thread: Lists: how to?
  • Next by thread: Re: Lists: how to?