Filtering for uniqueness in a list

Alex Tweedly alex at tweedly.net
Wed Oct 19 20:08:44 EDT 2005


Harvey Toyama wrote:

>Hi,
>
>I have a task that requires aggregating multiple lists and dropping
>non-unique entries. My lists come from MySQL tables.
>
>
>  
>
>2.  Read the lists into my Revolution client and perform 
>
>    the uniquification there 
>
> 
>
>    pro:  I don't compromise the MySQL security
>
>    con:  I think I have to use a REPEAT loop to 
>
>          compare subsequent lines in the sorted 
>
>          aggregate list
>
> 
>
>Does anyone have a good, fast method for ensuring uniqueness in a multi
>word list?
>
>  
>
If you are not concerned by the order of the eventual list, you can use

>
> split myVar by cr and TAB    -- assuming TAB doesn't appear in the data
> put the keys of myVar into otherVar
>
This converts it into an array, using the contents of each line as the 
key; since there are no TABs in the data, the content of each array 
element is null - but you don't care. This conversion automatically 
eliminates duplicates - so then you can just use "the keys of" the array.

Note the code fragment here overwrites "myVar" - you could do

> put myVar into otherVar
> split otherVar by cr and TAB
> put the keys of otherVar into otherVar


-- 
Alex Tweedly       http://www.tweedly.net



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.12.4/142 - Release Date: 18/10/2005




More information about the use-livecode mailing list