Re: Intersection problem

*To*: mathgroup at smc.vnet.net*Subject*: [mg125984] Re: Intersection problem*From*: Yi Wang <tririverwangyi at gmail.com>*Date*: Wed, 11 Apr 2012 18:18:45 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*References*: <jm0ju7$adk$1@smc.vnet.net>

There should be many ways to do it. The question is to find a good one. The simplest I can think of is: first = {{a, x}, {b, y}, {c, z}}; second = {b, c, d}; Select[first, MemberQ[second, #[[1]]] &] There are also some more complicated realisations, such as first[[#]] & /@ Flatten@Map[Position[Transpose[first][[1]], #] &, second] Best, Yi On Tuesday, April 10, 2012 2:28:23 AM UTC-4, 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?