MathGroup Archive 1999

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

Search the Archive

Re: Intersection and element counts

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20771] Re: [mg20615] Intersection and element counts
  • From: "Simons, F.H." <F.H.Simons at tue.nl>
  • Date: Thu, 11 Nov 1999 00:22:46 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Just for fun: the following solution works very fast when the two lists do
not contain numbers.

intersect[ list1_, list2_ ] := PolynomialGCD[ Times @@ list1, Times @@ list2
]

With

list1 = {a, b, b, a, c, d, b, b, c};
list2 = {a, b, d, b, b, a, d, c, c};

we obtain

a^2 b^3 c^2 d.

By applying List, followed by the simple substitution: Power[x_, n_] :>
Table[ x, {n}] and Flattening, the result may be given in the form of a
list, if desired.


Fred Simons
Eindhoven University of Technology


  • Prev by Date: Re: complex variable
  • Next by Date: Re: Re: Re:Color of GridLines
  • Previous by thread: Re: Re: Intersection and element counts
  • Next by thread: Re: Re: Intersection and element counts