Home | Trees | Index | Help |
|
---|
Package young :: Module combination |
|
Function Summary | |
---|---|
catalan(n) -> Return the Catalan number | |
catalan_generator() -> Return the Catalan number as a generator. | |
combination(n, m) -> Return the combination of (n,m). | |
factorial([m=1), n) -> Return the factorial of n. | |
k_composition(n, k) -> Return the number of k-composition of n. | |
permutation(sequence) -> Return the permutation of sequence | |
weak_k_composition(n, k) -> Return the number of weak k-composition of n. |
Function Details |
---|
catalan(num)catalan(n) -> Return the Catalan number>>> for i in range(10): ... print catalan(i) ... 1 1 2 5 14 42 132 429 1430 4862 |
catalan_generator()catalan_generator() -> Return the Catalan number as a generator.>>> g = catalan_generator() >>> for i in range(10): ... print g.next() ... 1 1 2 5 14 42 132 429 1430 4862 |
combination(first, second)combination(n, m) -> Return the combination of (n,m). n can be a sequence or an integer; m must be an integer. If n is an integer, return the combination of (n, m) If n is a sequence, take m elements out of the sequence.>>> n = 5 >>> for i in range(n): ... print combination(n, i) ... 1 5 10 10 5 >>> s = 'abcd' >>> for i in range(len(s) + 1): ... print combination(s, i) ... [[]] [['a'], ['b'], ['c'], ['d']] [['a', 'b'], ['a', 'c'], ['a', 'd'], ['b', 'c'], ['b', 'd'], ['c', 'd']] [['a', 'b', 'c'], ['a', 'b', 'd'], ['a', 'c', 'd'], ['b', 'c', 'd']] [['a', 'b', 'c', 'd']] |
factorial(x, y=0)factorial([m=1), n) -> Return the factorial of n. If m is given, multiply an iterable from m to n. i.e., m x (m+1) x ... x n>>> for i in range(10): ... print factorial(i) ... 1 1 2 6 24 120 720 5040 40320 362880 |
k_composition(n, k)k_composition(n, k) -> Return the number of k-composition of n.>>> n = 5 >>> for i in range(n): ... print k_composition(n, i+1) ... 1 4 6 4 1 |
permutation(*seq)permutation(sequence) -> Return the permutation of sequence>>> seq = range(3) >>> for x in sorted(permutation(seq)): ... print x ... [0, 1, 2] [0, 2, 1] [1, 0, 2] [1, 2, 0] [2, 0, 1] [2, 1, 0] >>> permutation(seq) == permutation(*seq) True |
weak_k_composition(n, k)weak_k_composition(n, k) -> Return the number of weak k-composition of n.>>> n = 5 >>> for i in range(n): ... print weak_k_composition(n, i+1) ... 1 6 21 56 126 |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Sun May 15 17:34:14 2005 | http://epydoc.sf.net |