PreviousNext…

Permutations

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.

Further reading

Downloads

Comments

Comments on this post are now closed.

About

I’m a developer / general IT wrangler, specialising in web apps, the mobile web, enterprise Java and the odd Domino system.

Best described as a simpleton, but kindly. Read more…


File Attachment Icon
permutate.zip