Re: Intersection problem

• To: mathgroup at smc.vnet.net
• Subject: [mg125985] Re: Intersection problem
• Date: Wed, 11 Apr 2012 18:19:05 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <201204100627.CAA10654@smc.vnet.net>

```Three solutions

In[1]:= Select[{{a, x}, {b, y}, {c, z}}, MemberQ[{b, c, d}, #1[[1]]] & ]
Out[1]= {{b, y}, {c, z}}
In[2]:= Cases[{{a, x}, {b, y}, {c, z}}, {i_, _} /; MemberQ[{b, c, d}, i]]
Out[2]= {{b, y}, {c, z}}
In[3]:= Cases[{{a, x}, {b, y}, {c, z}}, {Alternatives @@ {b, c, d}, _}]
Out[3]= {{b, y}, {c, z}}

2012/4/10 Cisco Lane <travlorf at yahoo.com>

> 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?
>
>

```

• Prev by Date: HostMath - Generate and embed math equations or mathematical formulas in a blog or website
• Next by Date: Re: Intersection problem
• Previous by thread: Re: Intersection problem
• Next by thread: Re: Intersection problem