StringTools - Maple Programming Help

Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Combinatorics on Words : StringTools/IsPalindrome

StringTools

 IsPalindrome
 test whether a string is a palindrome

 Calling Sequence IsPalindrome( s )

Parameters

 s - string

Description

 • The IsPalindrome(s) command returns the value true if s is a palindrome, and the value false otherwise. A palindrome is a string s that is equal to its reverse: $s=\mathrm{Reverse}\left(s\right)$.
 • If s is the empty string, the command returns true.
 • 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

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{IsPalindrome}\left(""\right)$
 ${\mathrm{true}}$ (1)
 > $\mathrm{IsPalindrome}\left("aaa"\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{IsPalindrome}\left("abc"\right)$
 ${\mathrm{false}}$ (3)
 > $\mathrm{IsPalindrome}\left("abcba"\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{IsPalindrome}\left("tenet"\right)$
 ${\mathrm{true}}$ (5)
 > $\mathrm{IsPalindrome}\left("tenets"\right)$
 ${\mathrm{false}}$ (6)
 > $\mathrm{IsPalindrome}\left("ROTOR"\right)$
 ${\mathrm{true}}$ (7)
 > $\mathrm{IsPalindrome}\left("civic"\right)$
 ${\mathrm{true}}$ (8)
 > $\mathrm{IsPalindrome}\left("semitimes"\right)$
 ${\mathrm{true}}$ (9)
 > $\mathrm{IsPalindrome}\left("aibohphobia"\right)$
 ${\mathrm{true}}$ (10)
 > $\mathrm{IsPalindrome}\left("ailihphilia"\right)$
 ${\mathrm{true}}$ (11)
 > $\mathrm{IsPalindrome}\left("kinnikinnik"\right)$
 ${\mathrm{true}}$ (12)
 > $\mathrm{IsPalindrome}\left("reliefpfeiler"\right)$
 ${\mathrm{true}}$ (13)
 > $\mathrm{IsPalindrome}\left("attordidrotta"\right)$
 ${\mathrm{true}}$ (14)
 > $\mathrm{IsPalindrome}\left("saippuakauppias"\right)$
 ${\mathrm{true}}$ (15)