You can treat structs as HashTable...

Something like this should work (not tested)

<cfset myList = "2,2,1,3,4,1,2,1">

<cfset tmpStruct = StructNew()>

<cfloop list="#myList#" delimiters="," index="current">
<cfset tmpStruct[current] = true>  <!--- add the number to the hash table --->
</cfloop>

<cfset myList = ""> <!--- re-set the list and rebuild it! --->
<cfloop collection="#tmpStruct#" item="current">
<cfset myList = ListAppend(myList, current)>
</cfloop>

-d

  ----- Original Message -----
  From: Owens, Howard
  To: CF-Talk
  Sent: Thursday, October 09, 2003 7:24 PM
  Subject: Hashtable in CF?

  Well, I don't know if a hashtable is exactly what I need since I'm not 100
  percent familiar with that kind of datastructure.

  But what I do need is a function that feeds in a long list of delminated
  data and parses out one copy of each unique value (where each value might be
  repeated several times).

  If I have a list of (2,2,1,3,4,1,2,1)

  How do I get (2,1,3,4) // order isn't important // ?

  You ever do anything like this? Sample code to share? A suggested algorithm?

  (Actually, as I write this, an idea springs to mind, but I'll post anyway in
  case there's a better idea out there or something I can learn from).

  H.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to