Elements of Free Monoids#
AUTHORS:
David Kohel (2005-09-29)
Elements of free monoids are represented internally as lists of pairs of integers.
- class sage.monoids.free_monoid_element.FreeMonoidElement(F, x, check=True)#
Bases:
MonoidElement
Element of a free monoid.
EXAMPLES:
sage: a = FreeMonoid(5, 'a').gens() sage: x = a[0]*a[1]*a[4]**3 sage: x**3 a0*a1*a4^3*a0*a1*a4^3*a0*a1*a4^3 sage: x**0 1 sage: x**(-1) Traceback (most recent call last): ... NotImplementedError
- to_list(indices=False)#
Return
self
as a list of generators.If
self
equals \(x_{i_1} x_{i_2} \cdots x_{i_n}\), with \(x_{i_1}, x_{i_2}, \ldots, x_{i_n}\) being some of the generators of the free monoid, then this method returns the list \([x_{i_1}, x_{i_2}, \ldots, x_{i_n}]\).If the optional argument
indices
is set toTrue
, then the list \([i_1, i_2, \ldots, i_n]\) is returned instead.EXAMPLES:
sage: M.<x,y,z> = FreeMonoid(3) sage: a = x * x * y * x sage: w = a.to_list(); w [x, x, y, x] sage: M.prod(w) == a True sage: w = a.to_list(indices=True); w [0, 0, 1, 0] sage: a = M.one() sage: a.to_list() []
See also
- sage.monoids.free_monoid_element.is_FreeMonoidElement(x)#