StringTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Distances and Metrics : StringTools/HammingDistance

StringTools

  

HammingDistance

  

compute the Hamming distance between two strings

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

HammingDistance( s, t )

Parameters

s

-

Maple string

t

-

Maple string

Description

• 

The HammingDistance(s,t) command returns an integer measure of the distance between the two strings s and t.

• 

The Hamming distance between two strings s and t, of equal length, is the number of character positions where they differ. If strings s and t have respective lengths m and n where, without loss of generality, n<m, then the generalized Hamming distance between s and t is defined to be (m - n) + HammingDistance( s[ 1 .. n ], t ). The HammingDistance procedure computes this generalized metric.

• 

For a different notion of the distance between two strings, see StringTools[Levenshtein].

Examples

useStringToolsinHammingDistanceMathematics&comma;Mathematischeend use

4

(1)

withStringTools&colon;

HammingDistanceabc&comma;abd

1

(2)

HammingDistanceabc&comma;abcd

1

(3)

HammingDistanceElisabeth&comma;Elyse

6

(4)

HammingDistanceConnor&comma;Constance

6

(5)

Since it is a metric, the Hamming distance satisfies the triangle inequality.

sRandom1000&comma;&apos;lower&apos;&colon;

tRandom1000&comma;&apos;lower&apos;&colon;

uRandom1000&comma;&apos;lower&apos;&colon;

HammingDistances&comma;t

955

(6)

HammingDistances&comma;u&plus;HammingDistanceu&comma;t

1926

(7)

See Also

string

StringTools

StringTools[Levenshtein]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam