Permutations 19 Jun, 2003
Background
I needed to build a function to generate all permutations of an array of items (where no item is repeated and item order is significant), so I wrote the script library contained in the following (R5) database. The agent 'Permutate' gives a demo of it working.
Notes formula language provides permuted list operators (e.g. '*+' and ' **'). For example, if I had the following list:
vList := "A" : "B" : "C" : "D"
then 'vList *+ vList' would give:
"AA" : "AB" : "AC" : "AD" : "BA" : "BB" : "BC" : "BD" : "CA" : "CB" : "CC"
: "CD" : "DA" : "DB" : "DC" : "DD"
'vList *+ vList *+ vList' would give:
"AAA" : "AAB" : "AAC" …
And so on. But what if you want to find all permutations where items are not repeated (i.e. items like "AAA" are excluded). This is more difficult to do efficiently in a generic way. The attached database contains a script library to meet this need.