You could use a query of query aswell if you wanted to, still using the udf 
method but using cffunction

<cffunction name="removeDuplicates">
        <cfargument name="list" required="Yes" />
        <cfscript>
                var qList = queryNew("");
                var qColumn = listToArray(arguments.list);
                var qReturn = "";
                
                queryAddColumn(qList, "list", qColumn);
        </cfscript>
        <cfquery dbtype="query" name="qReturn">
                SELECT  DISTINCT(list) AS listItem
                FROM    qList
        </cfquery>
        
        <cfreturn qReturn />
</cffunction>

<cfdump var="#removeDuplicates('test,hello,bla,test,smile')#">

The only thing using this way is that the query qill sort the list so you wont 
get it back in the same order as you passed it in.
manually you can do this.

The query will be heaps faster then sorting, storing, loop and the rest of it 
with the normal UDF method.

Steve

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Sheedy
Sent: Monday, January 10, 2005 11:46 AM
To: CFAussie Mailing List
Subject: [cfaussie] RE: Removing duplicates from a list

Thanks for the tip David. The udf uses the same technique that I'm currently 
using.. i.e. loop over the list and use listFind to
remove duplicates. The reason I'm looking for a simpler method is to reduce 
processing time for large lists. Encapsulating it in a
udf is handy though ..

Jason Sheedy
Senior Web Developer
Voice International Limited
www.voice.com.au


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Whiterod, David 
(DTUP)
Sent: Monday, 10 January 2005 10:20 AM
To: CFAussie Mailing List
Subject: [cfaussie] RE: Removing duplicates from a list

Hi Jason

Case-sensite: http://cflib.org/udf.cfm?ID=532 
Case-insensitive: http://cflib.org/udf.cfm?ID=533

Cheers

David

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jason Sheedy
Sent: Monday, 10 January 2005 10:23 AM
To: CFAussie Mailing List
Subject: [cfaussie] Removing duplicates from a list

Hi guys and gals,
does anyone know an easy way to remove duplicates from a list?

With all the handy list functions built into cf I would have thought this
one would be a must.

Jason Sheedy
www.voice.com.au

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
[EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/
b?\&v}?'?y z{jW?&i?Gj)Wj  Cu?wx v&z?? uw


---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to