### Navigation

- index
- modules |
- next |
- previous |
- Monoids »

# Monoid Elements

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: `sage.structure.element.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):
      ...
      TypeError: bad operand type for unary ~: 'FreeMonoid_class_with_category.element_class'

  `to_word`(alph=None)

    Return `self` as a word.

    INPUT:

    - `alph` – (optional) the alphabet which the result should be specified in

    EXAMPLES:

        sage: M.<x,y,z> = FreeMonoid(3)
        sage: a = x * x * y * x
        sage: w = a.to_word(); w
        word: xxyx
        sage: w.to_monoid_element() == a
        True

`sage.monoids.free_monoid_element.``is_FreeMonoidElement`(x)

  x.__init__(...) initializes x; see help(type(x)) for signature

### Navigation

- index
- modules |
- next |
- previous |
- Monoids »