MathGroup Archive 2002

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

Search the Archive

Re: irritating little problem


Hello,

Given a vector v,

v = {b, a, b, b, c, d, e, d, f, d, c, b, c, g};

I would recommend the following method. First, append the positions to the
values:

vv = Transpose[{v, Range[Length[v]]}]

Next, sort and split into sublists of equal values.

vs = Split[Sort[vv],  First[#1] == First[#2] & ]

What you do next depends upon details I don't know.

Hope this helps.

Tom Burton

On 2/18/02 11:36 PM, in article a4sv9c$ido$1 at smc.vnet.net, "KIMIC Weijnitz
Peter" <micweij at eka.ericsson.se> wrote:

> I have a simple vector
> and I want to find the position of elements that are equal.
> 
> I.e I want to test the vector and find all cases of similar elements.
> 
> Brute force is not what I want, it can be a long vector.
> Best regards
> Petr W
> 




  • Prev by Date: Re: Manipulating Pattern Matching ?
  • Next by Date: Re: Problems using Plot function
  • Previous by thread: Re: irritating little problem
  • Next by thread: RE: irritating little problem