Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2010

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

Search the Archive

List of multiple elements

  • To: mathgroup at
  • Subject: [mg112040] List of multiple elements
  • From: "Dr. Wolfgang Hintze" <weh at>
  • Date: Thu, 26 Aug 2010 06:48:34 -0400 (EDT)

Given the list


we can reduce multiple instances of elements using


The question is now how to compute the list of multiple elements.
In our example this would be m={1,1,2}.

A possible solution is

m[x_]:= Flatten[Take[#, {1, Length[#] - 1}] & /@ Select[Split[x], 
Length[#] > 1 &]]


I'm sure there is a much more elegant solution. Can you suggest one?


m[a] can be viewed as a kind of difference: m[a] = a "MINUS" Union[a]
Inverting gives the "SUM": a = m[a] "PLUS" Union[a] = 


  • Prev by Date: NotebookAutoSave?
  • Next by Date: Re: finding a symplectic recursion fixed point
  • Previous by thread: Re: NotebookAutoSave?
  • Next by thread: Re: List of multiple elements