Code for finding all classes of commuting functions on a given domain