Infinite word

AUTHORS:

  • Sebastien Labbe
  • Franco Saliola

EXAMPLES:

Creation of an infinite word

Periodic infinite words:

sage: v = Word([0, 4, 8, 8, 3])
sage: vv = v^Infinity
sage: vv
word: 0488304883048830488304883048830488304883...

Infinite words from a function f:\mathbb{N}\rightarrow A over an alphabet A:

sage: Word(lambda n: n%3)
word: 0120120120120120120120120120120120120120...
sage: def t(n):
...       return add(Integer(n).digits(base=2)) % 2
sage: Word(t, alphabet = [0, 1])
word: 0110100110010110100101100110100110010110...

or as a one-liner:

sage: Word(lambda n : add(Integer(n).digits(base=2)) % 2, alphabet = [0, 1])
word: 0110100110010110100101100110100110010110...

Infinite words from iterators:

sage: from itertools import count,repeat
sage: Word( repeat(4) )
word: 4444444444444444444444444444444444444444...
sage: Word( count() )
word: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,...

Infinite words from morphism

For example, let A=\{a,b\} and \mu : A^* \rightarrow A^* be the morphism defined by a\mapsto ab, b\mapsto ba:

sage: mu = WordMorphism('a->ab,b->ba'); print mu
WordMorphism: a->ab, b->ba
sage: mu.fixed_point('a')
word: abbabaabbaababbabaababbaabbabaabbaababba...

Infinite words in a specific combinatorial class:

sage: W = Words("ab"); W
Words over Ordered Alphabet ['a', 'b']
sage: f = lambda n : 'a' if n % 2 == 1 else 'b'
sage: W(f)
word: babababababababababababababababababababa...
class sage.combinat.words.infinite_word.InfiniteWord_class

Bases: sage.combinat.words.abstract_word.Word_class

length()

Returns the length of self.

EXAMPLES:

sage: f = lambda n : n % 6
sage: w = Word(f); w
word: 0123450123450123450123450123450123450123...
sage: w.length()
+Infinity

Table Of Contents

Previous topic

Finite word

Next topic

Word classes

This Page