A Coldfusion list (or any list for that matter) is simply a string. The thing that makes this string different (to any other string) is that it contains delimiters. Delimiters (sometimes referred to as separators) are used to separate each item in the list.
For example: ColdFusion Lists,ColdFusion Arrays,ColdFusion Structures could be a comma delimited, or comma separated list.
Although commas are the most common delimiter for lists, any character (or set of characters) can be used. For example, ColdFusion Lists:ColdFusion Arrays:ColdFusion Structures is no less a list than the comma delimited list.
Creating Lists in ColdFusion
This is easy. You can create a list in ColdFusion just the same you would create any other variable. Just remember to throw in a delimiter:
<cfset coldfusion_list = "ColdFusion Lists,ColdFusion Arrays,ColdFusion Structures">
In reality, you would probably create the list dynamically by looping through a set of items. You will often need to convert an array into a list or a list to an array (see below).
ColdFusion List Functions
Once you have your list, you can use ColdFusion to work with it. ColdFusion provides many functions for working with lists. Some of the common things you might need to do are listed below.
Find out the list length
Loop through the list
<cfloop list="#coldfusion_list#" index="i"> <cfoutput> #i#</cfoutput> </cfloop>
Add items to the list
Add an item to the end of the list. The following adds ColdFusion Functions to the end of the list:
listAppend(coldfusion_list, "ColdFusion Functions")
Add an item to the beginning of the list. The following adds ColdFusion Functions to the beginning of the list:
listPrepend(coldfusion_list, "ColdFusion Functions")
Add an item somewhere in the middle of the list. The following adds ColdFusion Functions to position 2 of the list:
listInsertAt(coldfusion_list, "2", "ColdFusion Functions")
The above functions also accept an optional delimiter field, which, if needed, you place at the end. For example:
listAppend(coldfusion_list, "ColdFusion Functions", ":")
Find out if the list contains a given string
...or if you don't want it to be case sensitive:
Convert a list into an array
Convert an array into a list