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.

Further reading


Comments on this post are now closed.


I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.

File Attachment Icon