Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9580

Re: Intersection problem

From Christoph Lhotka <christoph.lhotka@fundp.ac.be>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Intersection problem
Date 2012-04-12 08:41 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jm64gd$6ku$1@smc.vnet.net> (permalink)
References <201204100627.CAA10654@smc.vnet.net>

Show all headers | View raw


hello,

here is one solution:

list1 = {{a, x}, {b, y}, {c, z}};
list2 = {b, c, d};

Select[list1, Intersection[list2, #] != {} &]
{{b, y}, {c, z}}

best,

christoph

On 04/10/2012 08:27 AM, 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?
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Intersection problem Christoph Lhotka <christoph.lhotka@fundp.ac.be> - 2012-04-12 08:41 +0000

csiph-web