Permutations in Lexicographic Order
We generate permutations of a set of notes not in strict alphabetical order but in lexicographical order based on pitch.
For example, with base set {C, D, E }, we generate the string of notes CDE CED DCE DEC ECD ECD (with spaces added here for legibility).
Note that this same perumutation on a different set of notes, such as {C, E, G} or {C, D#, E} sounds somewhat similar but different.
We represent a function by beginning with the melody of the permutations of a set of notes in lexicographic order and then as the value of the function changes we change, generally one at a time, the notes in the base set.