Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Keith Gaughan http://talideon.com/

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Removing duplicates from lists

A request for this came up on the CF-Talk list recently. Here's what I came up with.
<!--- The list with want to clean up --->
<cfset lst = "a,list,with,a,few,duplicates">
<!--- Use a struct to build a set of the list elements --->
<cfset set = StructNew()>
<cfloop index="elem" list="#lst#">
    <cfset set[elem] = "">
</cfloop>
<!--- Convert the set back to a list --->
<cfset lst = StructKeyList(set)>

This sort of this should be familiar to all you perlmongers out there.
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS