Skip to content

Instantly share code, notes, and snippets.

@adrianblynch
Created April 30, 2013 16:44
Show Gist options
  • Save adrianblynch/5489993 to your computer and use it in GitHub Desktop.
Save adrianblynch/5489993 to your computer and use it in GitHub Desktop.
ListItemCombos
<cfoutput>
<cfset list = "a,b,c">
Original list: #list#<br /><br />
<cfset combos = {}>
<cfloop from="1" to="#ListLen(list)#" index="i">
<cfset workingList = list>
<cfset workingList = ListDeleteAt(workingList, i)>
<cfset currentItem = ListGetAt(list, i)>
<cfloop from="1" to="#ListLen(list)#" index="j">
<cfif j LT ListLen(list)>
<cfset combo = ListInsertAt(workingList, j, currentItem)>
<cfelse>
<cfset combo = ListAppend(workingList, currentItem)>
</cfif>
<cfset combo = ListChangeDelims(combo, "_", ",")>
<cfset combos[combo] = true>
</cfloop>
</cfloop>
<cfdump var="#combos#">
<cfabort>
abc
acb
bac
bca
cab
cba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment