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


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

Re: Intersection problem

From Alexei Boulbitch <Alexei.Boulbitch@iee.lu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Intersection problem
Date 2012-04-11 22:23 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jm509g$2ou$1@smc.vnet.net> (permalink)

Show all headers | View raw


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?




Try this:

Select[{{a, x}, {b, y}, {c, z}}, MemberQ[{b, c, d}, #[[1]]] &]

{{b, y}, {c, z}}

Have fun.


Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu



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


Thread

Re: Intersection problem Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2012-04-11 22:23 +0000

csiph-web