Wiki

Clone wiki

dart_trotter / compounds

Home | Permutations | Combinations | Amalgams | Compositions | Subsets | Compounds | Inverses | About

Compounds

The Compounds (permutations of unspecified length) constructor accepts one argument: a list containing the items in the set to be compounded.

For example, the following line creates a pseudo-list containing all the compounds of the strings "a" to "e".

var cp = new Compounds(characters("abcde"));

To see how many compounds are "contained" in cp, we can check cp.length. We can retrieve the individual subsets by index, e.g., cp[0].

How are Compounds arranged?

In this library, Compounds are arranged according to the order in which items appear in the list given during the construction, starting with the empty compound and ending with the permutations of the complete set of items. For example, consider the following set of trotters:

There are 326 possible compounds of this set. They are arranged by the algorithm as follows:

(dot, dot, dot)

Updated