def __init__(self, n, names=None): """ Create free monoid on `n` generators. INPUT: - ``n`` - integer - ``names`` - (optional) variable name or list of variable names EXAMPLES:: sage: F = FreeMonoid(3,'x'); F Free monoid on 3 generators (x0, x1, x2) sage: x = F.gens() sage: x[0]*x[1]**5 * (x[0]*x[2]) x0*x1^5*x0*x2 sage: F = FreeMonoid(3, 'a') sage: F Free monoid on 3 generators (a0, a1, a2) :: sage: M = FreeMonoid(3, names=['a','b','c']) sage: TestSuite(M).run() """ if not isinstance(n, (int, long, Integer)): raise TypeError, "n (=%s) must be an integer."%n if n < 0: raise ValueError, "n (=%s) must be nonnegative."%n self.__ngens = int(n) #self._assign_names(names) Monoid_class.__init__(self,names)
def __init__(self, n, names=None): """ Create free monoid on `n` generators. INPUT: - ``n`` - integer - ``names`` - (optional) variable name or list of variable names EXAMPLES:: sage: F = FreeMonoid(3,'x'); F Free monoid on 3 generators (x0, x1, x2) sage: x = F.gens() sage: x[0]*x[1]**5 * (x[0]*x[2]) x0*x1^5*x0*x2 sage: F = FreeMonoid(3, 'a') sage: F Free monoid on 3 generators (a0, a1, a2) :: sage: M = FreeMonoid(3, names=['a','b','c']) sage: TestSuite(M).run() """ if not isinstance(n, (int, long, Integer)): raise TypeError("n (=%s) must be an integer." % n) if n < 0: raise ValueError("n (=%s) must be nonnegative." % n) self.__ngens = int(n) #self._assign_names(names) Monoid_class.__init__(self, names)