PrefixDistance - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


StringTools

  

PrefixDistance

  

compute the prefix distance between two strings

  

SuffixDistance

  

compute the suffix distance between two strings

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

PrefixDistance( s, t )

SuffixDistance( s, t )

Parameters

s

-

Maple string

t

-

Maple string

Description

• 

The PrefixDistance(s,t) and SuffixDistance(s,t) commands return integer measures of the distance between the two strings s and t.

• 

Let s and t be arbitrary strings. The prefix distance PrefixDistance( s, t ) is defined to be lengths+lengtht2CommonPrefixs,t, and the suffix distance SuffixDistances,t is defined, similarly, to be lengths+lengtht2CommonSuffixs,t. Both are metrics.

• 

Other string metrics available in this package include StringTools[HammingDistance] and StringTools[Levenshtein].

• 

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

useStringToolsinPrefixDistanceMathematics,Mathematischeend use

6

(1)

withStringTools:

PrefixDistanceabc,abd

2

(2)

PrefixDistanceabc,abcd

1

(3)

PrefixDistanceElisabeth,Elyse

10

(4)

PrefixDistanceConnor,Constance

9

(5)

SuffixDistancefoe,Defoe

2

(6)

SuffixDistanceNorth America,Central America

12

(7)

SuffixDistanceNorth America,South America

6

(8)

SuffixDistanceabba,abba

0

(9)

Being metrics, both PrefixDistance and SuffixDistance satisfy the triangle inequality.

sRandom10,binary

s0000101110

(10)

tRandom10,binary

t1101110100

(11)

uRandom10,binary

u0100010001

(12)

SuffixDistances,t

18

(13)

SuffixDistances,u+SuffixDistanceu,t

40

(14)

See Also

string

StringTools

StringTools[CommonPrefix]

StringTools[CommonSuffix]

StringTools[HammingDistance]

StringTools[Levenshtein]