[New-bugs-announce] [issue5139] Add combinatoric counting functions to the math module.

Raymond Hettinger report at bugs.python.org
Tue Feb 3 05:57:47 CET 2009


New submission from Raymond Hettinger <rhettinger at 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 <report at bugs.python.org>
<http://bugs.python.org/issue5139>
_______________________________________


More information about the New-bugs-announce mailing list