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


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

Re: Intersection problem

From Fred Simons <f.h.simons@tue.nl>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Intersection problem
Date 2012-04-11 22:17 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jm4vtu$2k6$1@smc.vnet.net> (permalink)
References <201204100627.CAA10654@smc.vnet.net>

Show all headers | View raw


Op 10-4-2012 8:27, Cisco Lane schreef:
> 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?
>
>
I am not sure if this is quick, but it is short:

Pick[list1, list1[[All, 1]], Alternatives @@ list2]


Regards,

Fred Simons
Eindhoven University of Technology

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


Thread

Re: Intersection problem Fred Simons <f.h.simons@tue.nl> - 2012-04-11 22:17 +0000

csiph-web