Border - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


StringTools

  

Border

  

compute the border of a string

  

BorderLength

  

compute the length of the border of a string

  

BorderArray

  

compute a list of border lengths for substrings of a string

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Border( w )

BorderLength( w )

BorderArray( w )

Parameters

w

-

Maple string

Description

• 

The Border( w ) command computes the border of a string w. The border of a string (or word)  w is the maximal prefix of w that is also a suffix of w.

• 

The BorderLength( w ) command computes only the length of the border of the word w. It is, by definition, equal to length( Border( w ) ), but is more space efficient because the string Border( w ) is not constructed.

• 

The BorderArray( w ) command computes a list of border lengths for the length( w ) substrings of w, where the ith substring consists of the first i characters of w. That is, BorderArray( w ) is equal to [⁢BorderLength⁡w1⁢,BorderLength⁡w[1..2]⁢,...,BorderLength⁡w[1..length⁡w]⁢⁢].

• 

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

> 

with⁡StringTools:

> 

Border⁡

(1)
> 

Border⁡aaa

aa

(2)
> 

Border⁡ababab

abab

(3)
> 

Border⁡ab

(4)
> 

Border⁡aba

a

(5)
> 

Border⁡abcab

ab

(6)
> 

BorderLength⁡abcab

2

(7)
> 

BorderArray⁡abcab

0,0,0,1,2

(8)
> 

BorderArray⁡aaaab

0,1,2,3,0

(9)
> 

N≔100000:

> 

evalf⁡add⁡BorderLength⁡Random⁡20,binary,i=1..NN

1.630930000

(10)
> 

evalf⁡add⁡BorderLength⁡Random⁡20,dna,i=1..NN

0.4214100000

(11)
> 

evalf⁡add⁡BorderLength⁡Random⁡20,lower,i=1..NN

0.04103000000

(12)
> 

evalf⁡add⁡BorderLength⁡Random⁡20,print,i=1..NN

0.01095000000

(13)
> 

evalf⁡add⁡BorderLength⁡Random⁡20,i=1..NN

0.003670000000

(14)

See Also

string

StringTools

StringTools[Random]