Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #9397
| From | Dana DeLouis <dana01@me.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Find common elements in a list of sublists |
| Date | 2012-04-04 08:33 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jlh102$1j$1@smc.vnet.net> (permalink) |
> d={{1, 19}, {1, 23}, {1, 5, 25}, {1, 17}, {1, 11}, {1, 5}}
> How do I find the elements common to all the sublists?
Hi. If I understand the question correctly, using Apply is what you need:
d={{1,19},{1,23},{1,5,25},{1,17},{1,11},{1,5}};
Intersection@@d
{1}
= = = = = = = = = =
HTH :>)
Dana DeLouis
Mac & Math 8
= = = = = = = = = =
On Apr 3, 4:44 am, Cisco Lane <travl...@yahoo.com> wrote:
> Suppose I have a list of sublists:
>
> d={{1, 19}, {1, 23}, {1, 5, 25}, {1, 17}, {1, 11}, {1, 5}}
>
> How do I find the elements common to all the sublists?
>
> I can do it using intersection:
>
> Intersection[dx[[1]], dx[[2]], dx[[3]], dx[[4]], dx[[5]], dx[[6]]]
>
> which yields, correctly, {1}, but what if the number of sublists in d is variable?
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Find common elements in a list of sublists Dana DeLouis <dana01@me.com> - 2012-04-04 08:33 +0000
csiph-web