ThueMorse - Maple Help

StringTools

 ThueMorse
 generate a Thue-Morse string

 Calling Sequence ThueMorse( n, a, b )

Parameters

 n - non-negative integer; specifies that ThueMorse must return then nth Thue-Morse string a - character; (optional) first symbol to use b - character; (optional) second symbol to use

Description

 • The ThueMorse(n, a, b) command generates the length-n prefix of the (infinite) Thue-Morse string, with initial values a and b. The arguments after the first are optional, and default to the strings $"0"$ and $"1"$, respectively.
 • The Thue-Morse string is the infinite string defined to be the fixed point of the iterated semigroup morphism $0->01,1->10$ on the free semigroup generated by $\left\{0,1\right\}$.
 • A recursive definition of the Thue-Morse sequence is as follows. ${t}_{0}=0$, ${t}_{2n}={t}_{n}$, ${t}_{1+2n}=1-{t}_{n}$.
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{seq}\left(\mathrm{ThueMorse}\left(n\right),n=0..5\right)$
 ${""}{,}{"0"}{,}{"01"}{,}{"011"}{,}{"0110"}{,}{"01101"}$ (1)
 > $\mathrm{ThueMorse}\left(5,"a","b"\right)$
 ${"abbab"}$ (2)
 > $\mathrm{ThueMorse}\left(100\right)$
 ${"0110100110010110100101100110100110010110011010010110100110010110100101100110100101101001100101100110"}$ (3)