21 lines
524 B
Plaintext
21 lines
524 B
Plaintext
isPalindrome = function(s)
|
|
// convert to lowercase, and strip non-letters
|
|
stripped = ""
|
|
for c in s.lower
|
|
if c >= "a" and c <= "z" then stripped = stripped + c
|
|
end for
|
|
|
|
// check palindromity
|
|
mid = floor(stripped.len/2)
|
|
for i in range(0, mid)
|
|
if stripped[i] != stripped[-i - 1] then return false
|
|
end for
|
|
return true
|
|
end function
|
|
|
|
testStr = "Madam, I'm Adam"
|
|
answer = [testStr, "is"]
|
|
if not isPalindrome(testStr) then answer.push "NOT"
|
|
answer.push "a palindrome"
|
|
print answer.join
|