Hello there, is there a way to go through all possible permutations with repetitions of given data? for example, I have 16 slots for harmonics and each letter represents a different percentage in volume from 0 to 100%, "e" could represent 13% if you want: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p). Im using Iannix to control Pure Data so I imagine that in iannix when the curve is at the top it will start with all possible combinations and permutations with repetitions and when the curve is at the bottom it will end, and have gone through all possible combinations.
Im aware of the number of combinations possible and their vast space, with 5 slots for harmonics with a,b,c,d,e for volume, with its repetitions and permutations I got 3126 different combinations or timbres.
For example: the category for using 5 harmonic slots with 4 different volumes and one repetition of volume is this:
(if you have repetitions one letter will be left out)
1.aabcd 2.aabdc 3. aacbd 4. aacdb 5. aadbc 6.aadcb 7.abacd 8.abadc 9.abcad 10.abcda 11.abdac
12. abdca 13. acabd 14.acadb 15.acbad 16. acbda 17.acdab 18. acdba 19.adabc 20. adacb
21. adbac 22.adbca 23.adcab 24. adcba 25.baacd 26.baadc 27.bacad 28. bacda 29.badac 30.badca
31.bcaad 32. bcada 33.bcdaa 34.bdaac 35. bdaca 36.bdcaa 37.caabd 38.caadb 39.cabad 40.cabda
41.cadab 42.cadba 43.cbaad 44.cbada 45.cbdaa 46.cdaab 47.cdaba 48.cdbaa 49.daabc 50.daacb
51.dabac 52.dabca 53.dacab 54. dacba 55.dbaac 56.dbaca 57.dbcaa 58.dcaab 59.dcaba 60.dcbaa
Ultimately Id like to use 32 harmonic slots with 32 letters for volume or maybe 10 letters for volume with 32 harmonic slots, is there an algorithm to this?
Can someone help me?!
Thank you!

all possible permutations with repetitions of harmonic volume from top to bottom

This should generate all possible combinations of elements of a symbol or a list. Elements will also be combined with themselves.
The number of all combinations is n^n. On my computer it worked with a list of six elements, but crashed Pd with a list of seven.
Input: abc
Output: aaa, aab, aac, aba, abb, abc, aca, acb, acc, baa, bab, bac, bba, bbb, bbc, bca, bcb, bcc, caa, cab, cac, cba, cbb, cbc, cca, ccb, ccccombinations.pd (old)
combinationshelp.pd (old)It basically just counts up in an nary numeral system, n being the length of the list.

This version generates every combination directly from the previous one and is therefor in theory only limited by computer memory. On my computer it generated all 823543 combinations of 1 2 3 4 5 6 7 within a few minutes.
It can output the results in variable length, which can be set via creation argument or right inlet. If no length is provided, the results will have the same length as the original.

Input: abc
Output of [combinations]:
aaa, aab, aac, aba, abb, abc, aca, acb, acc, baa, bab, bac, bba, bbb, bbc, bca, bcb, bcc, caa, cab, cac, cba, cbb, cbc, cca, ccb, ccc 
Input: abcd
Output of [combinations 2]:
aa, ab, ac, ad, ba, bb, bc, bd, ca, cb, cc, cd, da, db, dc, dd 
Input: ab
Output of [combinations 4]:
aaaa, aaab, aaba, aabb, abaa, abab, abba, abbb, baaa, baab, baba, babb, bbaa, bbab, bbba, bbbb
The right outlet sends a bang when the generation is complete.
combinations.pd
combinationshelp.pdHow it works:
Internally, the patch uses lists of numbers 0, 1, ..., n1; n being the length of the original list. These numbers serve as digits of an nary system. It starts with a list of zeros. The digits of each list are send to the right branch (output) and the left branch (iteration) of the patch.At each iteration, one is added to the first digit of the list. If the result equals n [mod] sets it to zero and [div] takes the carryover (1) to the next digit. If there is still a carryover after the last operation, meaning that the current combination is the last one, the spigot is closed and it stops.
Before the output, the internal digits of each list are replaced with the numbers or symbols of the original list. Zero is replaced with the first element, one with the second and so on.
After each iteration a delay 0 is used to brake the loop and avoid stack overflow.
Uses [listdrip] from listabs extension.


@ingox Thanks for sharing this patch, it looks like it does exactly what I was hoping to achieve with my patch but in a much more elegant and versatile way, so I think I'll abandon my attempt!

@ingox your patch is great, and generates the sequence just how i pictured it, but now how do I apply it in iannix? this is the score i made with iannix...DS3.iannix , each pink curve represents pitch and the other colored curves are for morphing timbre, there are 31 pink curves and another 31 green ones or whatever that color is... each green one will control the timbre of an individual pink one...
how do I apply your patch with the iannix score? there will be 8 harmonics with 4 different positions in volume each for a start (25%, 50%, 75% and 100%), and the change has to be continuous, if the curve is continuous; If its rectangular at any point and cuts off instantly there will be a jump from timbre to timbre. 
@Pándinus i don't know anything about iannix and have only basic knowledge of music theory...

@ingox here, i made a simple score with iannix, and the patch for pure data to sound the curve... the red curve is pitch and the green one with vertical lines at times is for the timbre...pd 1 voz.pd , iannixSimple curve.iannix

@ingox download if you can the pd that is just attached to sound the curve, and download iannix , its free, ill explain everything,

@ingox I know very little about programming, were so close to finishing, how do I connect this patch to 8 sine waves with 4 volume percentages each? the last step would be only for the curve in iannix to control the movement of the sliders...