StringTools
DifferencePositions
compute the character positions at which two strings differ
Calling Sequence
Parameters
Description
Examples
Compatibility
DifferencePositions( s, t )
s
-
string
t
The DifferencePositions( s, t ) function computes the positions at which the strings s and t differ. It returns the (ordered) expression sequence of these positions. If s and t are equal, then NULL is returned. If s and t differ in length, then the positions up to the shorter of s and t are computed and returned.
The length of the returned expression sequence is equal to the Hamming distance between s and t, provided that s and t are the same length. (Note that the HammingDistance command computes the generalized Hamming distance for strings of unequal length.)
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.
withStringTools:
DifferencePositionsabc,abc
DifferencePositionsabcde,axcye
2,4
HammingDistanceabcde,axcye
2
DifferencePositionsabcde,axcyefg
HammingDistanceabcde,axcyefg
4
DifferencePositionsedit,tide
1,2,3,4
IsDerangementedit,tide
true
The StringTools[DifferencePositions] command was introduced in Maple 18.
For more information on Maple 18 changes, see Updates in Maple 18.
See Also
HammingDistance
IsDerangement
Download Help Document