New submission from Raymond Hettinger <rhettin...@users.sourceforge.net>:
To parallel the functions in itertools, add: math.combinations(n,r) --> n! / r! / (n-r)! when 0 <= r <= n or zero when r > n. math.permutations(n,r) --> n! / (n-r)! when 0 <= r <= n or zero when r > n. math.combinations_with_replacement(n,r) --> (n+r-1)! / r! / (n-1)! when n > 0. And when n==0, return 0 if r>0 else 1. These will enable an itertools user to compute the length of those iterators. It will also serve for general probability computations. Likewise, it produce binomial coefficients and multiset partitions. Since, the math module is where we put the factorial() function, it is the logical place for the combinatoric counting functions. ---------- components: Extension Modules messages: 81026 nosy: rhettinger priority: normal severity: normal status: open title: Add combinatoric counting functions to the math module. type: feature request versions: Python 2.7, Python 3.1 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5139> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com