Created
April 30, 2013 16:44
-
-
Save adrianblynch/5489993 to your computer and use it in GitHub Desktop.
ListItemCombos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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