One of possible solutions:

<!--- Original list --->

<cfset list="a,b,c,d">

<!--- Convert to array to make life easier --->

<cfset list=ListToArray(list)>

<!--- Number of iterations --->

<cfset n=ArrayLen(list)-1>

<!--- Result --->

<cfset res=ArrayNew(2)>

<!--- Permutations of length 1 --->

<cfset res[1]=list>

<!--- n iterations --->

<cfloop index="i" from="1" to="#n#">

<!--- Next length: Outer product of res[i] and list --->

<cfset prod=ArrayNew(1)>

<cfloop index="j" from="1" to="#ArrayLen(res[i])#">

<cfloop index="k" from="1" to="#ArrayLen(list)#">

<cfset ArrayAppend(prod, "#res[i][j]##list[k]#")>

</cfloop>

</cfloop>

<!--- Append permutations of length i+1 --->

<cfset ArrayAppend(res, prod)>

</cfloop>

<!--- Display results --->

<cfoutput>

<cfloop index="i" from="1" to="#ArrayLen(res)#">

Permutations of length #i#:<br>

#ArrayToList(res[i])#<hr>

</cfloop>

</cfoutput>

## Bookmarks