Counting and numbering duplicates in a list

Peter M. Brigham, MD pmbrig at
Thu Sep 29 08:36:08 EDT 2011

On Sep 29, 2011, at 8:00 AM, Roger Eller wrote:

> Good morning all,
> Thank you all for the juicy brain nuggets!  They look great, and I can't
> wait to try them.  Arrays are still a bit of a mystery to me, but I'm always
> reading great things about the speed gains when used, so... I'm off to do
> some tests...  Thanks everyone!
> ˜Roger
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

I discovered a minor bug in my suggestion, so for your testing use this instead of my original script:

function flagDupes tList
   put the millisecs into tStart
   put tList into scratchList
   repeat for each line t in tList
      delete line 1 of scratchList
      if t is among the lines of scratchList or \
             freqArray[t] > 0 then
         add 1 to freqArray[t]
         put cr & t & "-" & freqArray[t] after outputList
         put cr & t after outputList
      end if
   end repeat
   put the millisecs into tFinish
   put (tFinish - tStart)/1000 && "seconds" into elapsedTime
   return outputList
   put elapsedTime
end flagDupes

It turns out this is faster than I thought, about 1/3 second for 10000 lines on my machine.

-- Peter

Peter M. Brigham
pmbrig at

More information about the Use-livecode mailing list