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

MathGroup Archive 2012

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

Search the Archive

Re: Intersection problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125992] Re: Intersection problem
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Wed, 11 Apr 2012 18:21:32 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 4/10/12 at 2:27 AM, travlorf at yahoo.com (Cisco Lane) wrote:

>I need to select out the elements of the first list whose first
>elements are contained in the second list. For example

>first list: {{a,x},{b,y},{c,z}}

>second list: {b,c,d}

>result: {{b,y},{c,z}}

>Is there a quick way to do this? Intersection, maybe somehow?

In[1]:= Cases[{{a, x}, {b, y}, {c,
   z}}, _?(Intersection[#, {b, c, d}] != {} &)]

Out[1]= {{b, y}, {c, z}}




  • Prev by Date: Re: Intersection problem
  • Next by Date: Re: Intersection problem
  • Previous by thread: Re: Intersection problem
  • Next by thread: Re: Intersection problem