Example:
class ExampleCombinatorialClass_size(CombinatorialClass):
def __init__(self, size):
self.size = size
def __contains__(self, x):
if not isinstance(x, __builtin__.list):
return False
if len(x) != self.size:
return False
for i in x:
if not ( i == 0 or i == 1 ):
return False
return True
def size(self):
return self.size
def first(self):
return [0]*int(self.size)
def next(self, x):
try:
pos = x.index(0)
except:
return None
return [0]*int(pos) + [1] + x[pos+1:]sage: p5 = Partitions(5); p5 Partitions of the integer 5 sage: type(p5) <class 'sage.combinat.partition.Partitions_n'> sage: p5.list() [[5], [4, 1], [3, 2], [3, 1, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]] sage: p5.count() 7 sage: p5.first() [5] sage: p5.last() [1, 1, 1, 1, 1] sage: p5.random() [3, 2] sage: p5.unrank(1) [4, 1] sage: p5[1] [4, 1] sage: [i for i in p5] [[5], [4, 1], [3, 2], [3, 1, 1], [2, 2, 1], [2, 1, 1, 1], [1, 1, 1, 1, 1]] sage: p5.rank([4,1]) 1
Future:
Combinatorial Species (see http://www.risc.uni-linz.ac.at/people/hemmecke/aldor/combinat/ )
- Free Lie Algebra
- Hall-Littlewood polynomials / Macdonald polynomials
- Hopf algebras
- BMW algebra / graded BMW algebra / affine BMW algebra
- Temperley-Lieb algebra
- Double Schubert polynomials
- ...