MathGroup Archive 2006

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

Search the Archive

Re: Extract values and multilpicities from list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64890] Re: Extract values and multilpicities from list
  • From: dh <dh at metrohm.ch>
  • Date: Tue, 7 Mar 2006 06:11:41 -0500 (EST)
  • References: <due96k$ach$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Wolfgang,.
the following will do it:

{#[[1]], Length[#]} & /@  Split @  Sort @ lstIn

Daniel

Dr. Wolfgang Hintze wrote:
> Given a list of integers which may repeat, e.g.
> 
> lstIn = {2,3,4,4,2,1,1,5,4}
> 
> provide a list of different values and their respective multiplicities,
> in the example,
> 
> LstOut= {{1,2},{2,2},{3,1},{4,3},{5,1}}
> 
> Who finds the shortest function doing this task in general?
> 
> Thanks.
> 
> Best regards,
> Wolfgang
> 


  • Prev by Date: Re: mathematica to word
  • Next by Date: Re: Distinguished logarithm, branch cuts, etc.
  • Previous by thread: Re: Extract values and multilpicities from list
  • Next by thread: Re: Extract values and multilpicities from list