Anyone have a PERMUTATIONS function?

This topic is 6980 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Basically, what I am looking for is a custom function that can take a value list and create every permutation of the items in the value list. Say I have a value list "cat;dog;mouse", I want to be able to feed the custom function that value list and get:

cat dog mouse

cat mouse dog

dog cat mouse

dog mouse cat

mouse cat dog

mouse dog cat

The order of the permutations doesn't matter as long as all the permutations are returned. Also, the number of values in the list I feed it is variable. One time it may be three values as above, another time it may be four and so on.

Anybody help? I have been staring at my screen for hours. I am hoping this is easy for someone.

Share on other sites

Let ([

a = ValueListItems ( flName; List Name ); /* get the items in your list */

b = PatternCount ( b ; "

Share on other sites

Thanks for the thoughts. I was hoping someone would have a recursive function that would eliminate the need for all that code. I am actually currently hard coding it, but it's not very flexible.

Share on other sites

Try adapting this custom function from Jed Verity:

There's also a sub function that's required:

Share on other sites

I don't understand what a recursive function is or what it does or means? Anyone?

Share on other sites

A recursive function is a function that calls itself until a condition has been meet. Excelisys has a good pdf on this subject on their web site. http://www.excelisys.com

Share on other sites

A recursive function recurs, i.e. loops until a condition is met. Somewhat similar to a looping script with Exit Loop If[]. In Developer7 you can write custom functions, and a custom function can call itself, thus being recursive.

Example:

Custom Function:

CountFromTo ( start ; end )

Returns a comma-separated list of integers starting from start and ending with end.

Case (

start <= end ;

start & ", " & CountFromTo ( start + 1 ; end )

)

Share on other sites

Try adapting this custom function from Jed Verity:

There's also a sub function that's required:

That did the trick!!! Thanks.

Share on other sites

• 3 months later...

Hi,

attached my little contribution to your problem...

two custom functions: one for five characters and one for five fields.

permutazioni.zip

Share on other sites

This topic is 6980 days old. Please don't post here. Open a new topic instead.

Create an account

Register a new account