Counting and numbering duplicates in a list

dunbarx at aol.com dunbarx at aol.com
Thu Sep 29 00:42:22 EDT 2011


How fast is this with your list?:


on mouseUp


  repeat for each line tLine in yourList
    add 1 to dupCounter[tLine]
  end repeat
combine dupCounter with return and comma
put dupCounter into yourOutputContainer
end mouseUp


Craig Newman





-----Original Message-----
From: Roger Eller <roger.e.eller at sealedair.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Wed, Sep 28, 2011 6:53 pm
Subject: Counting and numbering duplicates in a list


There are several ways I could approach this, but I'm unsure which way is
best?  I have a list of numbers that 'may' contain duplicates.  I need to
sequence ONLY the duplicates without changing the order the list. If there
is only one, it does not need to be sequenced.

Should I just repeat, and keep the content of line x in a variable, then add
1 to a sequence variable if the number is encountered again?  Is there a
better way?  Simple stuff, I know, but these lists can be really long, and I
want it to process as quickly possible.

12345
12345
12344
12333
10112
12333

must become:

12345-1
12345-2
12344
12333-1
10112
12333-2

˜Roger
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 




More information about the Use-livecode mailing list