StringTools - Maple Programming Help

Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Combinatorics on Words : StringTools/IsPrimitive

StringTools

 IsPrimitive
 test whether a string is primitive

 Calling Sequence IsPrimitive( s )

Parameters

 s - string

Description

 • The IsPrimitive(s) command returns the value true if s is primitive, and the value false otherwise. A string is primitive if it cannot be written as a proper power of another string. In other words, s is primitive if $\mathrm{Repeat}\left(t,n\right)=s$ implies that either $s=""$ or $s=t$ and $n=1$.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{IsPrimitive}\left(""\right)$
 ${\mathrm{false}}$ (1)
 > $\mathrm{IsPrimitive}\left("a"\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{IsPrimitive}\left("aaa"\right)$
 ${\mathrm{false}}$ (3)
 > $\mathrm{IsPrimitive}\left("abc"\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{IsPrimitive}\left("abcabc"\right)$
 ${\mathrm{false}}$ (5)
 > $\mathrm{seq}\left(\mathrm{IsPrimitive}\left(\mathrm{ThueMorse}\left(n\right)\right),n=1..30\right)$
 ${\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}$ (6)
 > $\mathrm{andmap}\left(\mathrm{IsPrimitive},\mathrm{LyndonFactors}\left(\mathrm{Random}\left(1000,'\mathrm{lower}'\right)\right)\right)$
 ${\mathrm{true}}$ (7)