|
Calling Sequence
|
|
Period( w )
|
|
Parameters
|
|
|
|
Description
|
|
•
|
The Period(w) command computes the period of a string (word) w. A positive integer p is said to be a period of a string s if, for all integers i with , one has . The least period of the string s is called the period of s.
|
•
|
All of the StringTools package commands treat strings as (null-terminated) sequences of -bit (ASCII) characters. Thus, there is no support for multibyte character encodings, such as unicode encodings.
|
|
|
Examples
|
|
>
|
seq( Period( Fibonacci( n ) ), n = 1 .. 10 );
|
| (5) |
>
|
seq( combinat[ 'fibonacci' ]( n ), n = 1 .. 10 );
|
| (6) |
>
|
seq( Period( ThueMorse( n ) ), n = 1 .. 10 );
|
>
|
Periodic? := w -> evalb( Period( w ) <= floor( length( w ) / 2 ) );
|
| (8) |
>
|
( Period, length, Periodic? )( "ababababababababa" );
|
>
|
( Period, length, Periodic? )( "abcdeab" );
|
|
|
|