in reply to Obtaining terms in an expansion
Actually 2**N is the number of subsets of a set of cardinality N, while the number of permutations of a set of N distinct elements is N! (facultyfactorial).
ivancho used the subset theme quite succesfully in this node above.
However, the module Math::Combinatorics can still be used to iterate through the 2**N subsets as well as the nCr combinations and the N! permutations.
Thank you, for pointing me to the "factorial"
Note to self: Don't transfer mathematical/technical terms from German to English without consulting a dictionary first.
Also, would you be able to give example code for the subset iteration with Math::Combinatorics?
If there is an easy way to do so, it has escaped me.
The closest I saw in the docs was that example to generate:"Morse signals: diferent signals of 3 positions using the two symbols - and .".
Now Morse signals of length 3 are surely one-to-one and onto the subsets of a 3 element set (set elements = pos in signal; element not/contained = dot/dash)
The given iteration using next_multiset and next_string is like computing 2**n as sumk=0..n nCk
At least this is not trivial application of the modules methods.
15 years from now, by which time it will be a completely different language
It's just a number, so who cares?
Results (117 votes). Check out past polls.