pepper.Rd
Given a list of variables, construct every term comprising only those
variables; function pepper()
returns a free algebra object
equal to the sum of these terms.
The function is named for a query from an exam question set by Sarah Marshall in which she asked how many ways there are to arrange the letters of word “pepper”, the answer being \(\left({6\atop 1\,2\,3}\right)=\frac{6!}{1!2!3!}=60\).
Function multiset()
in the partitions package gives
related functionality; for the record, one way to reproduce
pepper("pepper")
would be
pepper(v)
pepper(c(1,1,1,1,1,1,2)) # 6 a's and 1 b
#> free algebra element algebraically equal to
#> + aaaaaab + aaaaaba + aaaabaa + aaabaaa + aabaaaa + abaaaaa + baaaaaa
pepper(c(1,2,2,2,3)) # 1 a, 3 b's and 1 c
#> free algebra element algebraically equal to
#> + abbbc + abbcb + abcbb + acbbb + babbc + babcb + bacbb + bbabc + bbacb + bbbac
#> + bbbca + bbcab + bbcba + bcabb + bcbab + bcbba + cabbb + cbabb + cbbab + cbbba
pepper("pepper")
#> free algebra element algebraically equal to
#> + eepppr + eepprp + eeprpp + eerppp + epeppr + epeprp + eperpp + eppepr +
#> epperp + eppper + epppre + epprep + epprpe + eprepp + eprpep + eprppe + ereppp
#> + erpepp + erppep + erpppe + peeppr + peeprp + peerpp + pepepr + peperp +
#> pepper + peppre + peprep + peprpe + perepp + perpep + perppe + ppeepr + ppeerp
#> + ppeper + ppepre + pperep + pperpe + pppeer + pppere + pppree + ppreep +
#> pprepe + pprpee + preepp + prepep + preppe + prpeep + prpepe + prppee + reeppp
#> + repepp + reppep + repppe + rpeepp + rpepep + rpeppe + rppeep + rppepe +
#> rpppee