def cardinality(self): """ The cardinality of ``self`` This is a Catalan number. TESTS:: sage: BinaryTrees(0).cardinality() 1 sage: BinaryTrees(5).cardinality() 42 """ return catalan_number(self._size)
def cardinality(self): r""" Returns the number of Dyck words of size n, i.e. the n-th Catalan number. EXAMPLES:: sage: DyckWords(4).cardinality() 14 sage: ns = range(9) sage: dws = [DyckWords(n) for n in ns] sage: all([ dw.cardinality() == len(dw.list()) for dw in dws]) True """ if self.k2 == self.k1: return catalan_number(self.k1) else: return len(self.list())
def cardinality(self): """ The cardinality of ``self`` This is a Catalan number TESTS:: sage: OrderedTrees(0).cardinality() 0 sage: OrderedTrees(1).cardinality() 1 sage: OrderedTrees(6).cardinality() 42 """ if self._size == 0: return Integer(0) else: return catalan_number(self._size-1)
def cardinality(self): """ The cardinality of ``self`` This is a Catalan number TESTS:: sage: OrderedTrees(0).cardinality() 0 sage: OrderedTrees(1).cardinality() 1 sage: OrderedTrees(6).cardinality() 42 """ if self._size == 0: return Integer(0) else: return catalan_number(self._size - 1)
def cardinality(self): """ Returns the number of non-decreasing parking functions of size `n`. This number is the `n`-th :func:`Catalan number<sage.combinat.combinat.catalan_number>`. EXAMPLES:: sage: PF = NonDecreasingParkingFunctions(0) sage: PF.cardinality() 1 sage: PF = NonDecreasingParkingFunctions(1) sage: PF.cardinality() 1 sage: PF = NonDecreasingParkingFunctions(3) sage: PF.cardinality() 5 sage: PF = NonDecreasingParkingFunctions(5) sage: PF.cardinality() 42 """ return catalan_number(self.n)