Compare - Maple Help

StringTools

 Compare
 perform lexicographical order comparison of strings
 CompareCI
 perform case-insensitive lexicographical order comparison of strings

 Calling Sequence Compare( s1, s2 ) CompareCI( s1, s2 )

Parameters

 s1, s2 - Maple strings

Description

 • The Compare(s1, s2) function performs a lexicographical order comparison between its two string arguments, s1 and s2.
 • The value true or false is returned according to the following table.

 String Order Return Value s1 precedes s2 true s1 is identical to s2 true s1 follows s2 false

 • The CompareCI(s1, s2) function performs a case-insensitive lexicographical order comparison between its two string arguments, s1 and s2.
 • The value true or false is returned according to the table above, apart from distinctions in letter case.
 • Note: The CompareCI procedure is equivalent to, but more efficient than, (s1, s2) -> Compare(LowerCase(s1), LowerCase( s2 )).
 • These procedures are part of the StringTools package, and so they can be used in the form Compare(..) only after executing the command with(StringTools). However, they can always be accessed through the long form of the command by using the form StringTools[Compare](..).
 • 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.

 • The StringTools[Compare] and StringTools[CompareCI] commands are thread-safe as of Maple 15.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{Compare}\left("abc","abb"\right)$
 ${\mathrm{false}}$ (1)
 > $\mathrm{Compare}\left("abc","abd"\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{Compare}\left("abc","abc"\right)$
 ${\mathrm{true}}$ (3)
 > $\mathrm{Compare}\left("abc","abcd"\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{Compare}\left("abcd","abc"\right)$
 ${\mathrm{false}}$ (5)
 > $\mathrm{Compare}\left("abc","ABC"\right)$
 ${\mathrm{false}}$ (6)
 > $\mathrm{Compare}\left("XYZ","xyz"\right)$
 ${\mathrm{true}}$ (7)
 > $\mathrm{Compare}\left("abc","ABC"\right)$
 ${\mathrm{false}}$ (8)
 > $\mathrm{CompareCI}\left("abc","ABC"\right)$
 ${\mathrm{true}}$ (9)
 > $\mathrm{Compare}\left("ABC","abc"\right)$
 ${\mathrm{true}}$ (10)
 > $\mathrm{CompareCI}\left("ABC","abc"\right)$
 ${\mathrm{true}}$ (11)
 > $\mathrm{CompareCI}\left("abc","abb"\right)$
 ${\mathrm{false}}$ (12)