Palindrome detection: Difference between revisions

Line 3,881:
}
?></lang>
 
=={{header|Picat}}==
<lang Picat>go =>
Tests = ["In girum imus nocte et consumimur igni",
"this is a non palindrome string",
"anna ABcdcBA anna",
"anna ABcdcBA annax",
"A man, a plan, a canoe, pasta, heros, rajahs" ++
"a coloratura, maps, snipe, percale, macaroni, " ++
"a gag, a banana bag, a tan, a tag, " ++
"a banana bag again (or a camel), a crepe, pins, " ++
"Spam, a rut, a Rolo, cash, a jar, sore hats, " ++
"a peon, a canal - Panama!",
10,
111111,
12221,
9384212,
10.01
],
 
foreach(Test in Tests)
if is_palindrome(Test) then
println([Test, "exact palindrome"])
elseif is_palindrome_inexact(Test) then
println([Test, "inexact palindrome"])
else
println([Test, "no"])
end
end,
nl.
 
% Detect palindromes for strings (and numbers).
is_palindrome(N), number(N) => is_palindrome(N.to_string()).
is_palindrome(S) => S == S.reverse().
 
% Detect inexact palindromes.
is_palindrome_inexact(N), number(N) => is_palindrome_inexact(N.to_string()).
is_palindrome_inexact(S) =>
is_palindrome(strip(S)).</lang>
 
{{out}}
<pre>[In girum imus nocte et consumimur igni,inexact palindrome]
[this is a non palindrome string,no]
[anna ABcdcBA anna,exact palindrome]
[anna ABcdcBA annax,no]
[A man, a plan, a canoe, pasta, heros, rajahsa coloratura, maps, snipe, percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats, a peon, a canal - Panama!,inexact palindrome]
[10,no]
[11,exact palindrome]
[111111,exact palindrome]
[12221,exact palindrome]
[9384212,no]
[10.01,exact palindrome]</pre>
 
=={{header|PicoLisp}}==
495

edits