comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Count duplicate elements in an array but keep their order!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Count duplicate elements in an array but keep their order! [message #85750] Fri, 30 August 2013 16:23 Go to previous message
Steve Daal is currently offline  Steve Daal
Messages: 13
Registered: October 2011
Junior Member
Hi,

I have a long array that looks like:
a =[
-120.09796
-120.09796
-108.18972
-108.18972
-108.18972
-121.98
-95.23
-95.23
-95.23
-95.23
-95.23
-95.23
-95.23
-95.23
-95.23
-95.23
-95.23
-95.23
-95.23
-95.03
-95.03
-95.03
-95.03
-71.303756
-122.39084
-122.39084
-122.39084
-122.24503]

with many more elements inside. I need to create two new arrays with the consecutive counts corresponding to the values of the first array after removing the duplicates, for instance, the above array would give me:
a_new = [-120.09796, -108.18972, -121.98, -95.23, -71.303756, -122.24503]
and
b_new = [2, 3, 1, 13, 1, 4]

where, elements -120.09796" existed twice in the original array and so forth.
Any help is much appreciated.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Evenly timed events in a widget program
Next Topic: Texture image on a 3d curve: cgsurface and xobjview problems

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:22:52 PDT 2025

Total time taken to generate the page: 0.00484 seconds