MathGroup Archive 1999

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

Search the Archive

Re: Intersection and element counts

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20647] Re: [mg20615] Intersection and element counts
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Sun, 7 Nov 1999 02:09:53 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Here is one rather obvious (and probably fairly ineffcient) solution:

In[11]:=
myintersection[l_,m_]:=Flatten[Map[Table[#,{i,1,Min[Count[l,#],Count[m,#]]}]
&,Intersection[l,m]]]


-- 


> From: "Arturas Acus" <acus at itpa.lt>
> Date: Thu, 4 Nov 1999 02:13:31 -0500
> To: mathgroup at smc.vnet.net
> Subject: [mg20647] [mg20615] Intersection and element counts
> 
> Dear Group
> 
> I am interesting in intersecion, which takes into
> account the number of the same elements.
> 
> It is I would like
> 
> myIntersection[{a,a,a,b,b,c},{a,a,b,b}]
> 
> to give me {a,a,b,b}.
> 
> Any solutions?
> Do theoretical speed of this function is
> very different of usual intersection algorithm speed?
> 
> 
> 
> Dr. Arturas Acus
> Institute of Theoretical
> Physics and Astronomy
> Gostauto 12, 2600,Vilnius
> Lithuania 
> 
> 
> E-mail: acus at itpa.lt
> Fax: 370-2-225361
> Tel: 370-2-612906
> 



  • Prev by Date: "Developer Project Information" Russell Towle
  • Next by Date: Mathsource File
  • Previous by thread: Re: Intersection and element counts
  • Next by thread: Re: Intersection and element counts