MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Find common elements in a list of sublists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125829] Re: Find common elements in a list of sublists
  • From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
  • Date: Wed, 4 Apr 2012 04:31:25 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

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?


Try this:

d={{1,19},{1,23},{1,5,25},{1,17},{1,11},{1,5}};

Intersection@@d

{1}

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 at iee.lu







  • Prev by Date: Re: how to make formatted output with Grid and Print?
  • Next by Date: Re: Find common elements in a list of sublists
  • Previous by thread: Re: Find common elements in a list of sublists
  • Next by thread: Re: Find common elements in a list of sublists