Palindrome detection: Difference between revisions

Content added Content deleted
(PascalABC.NET)
Line 3,259: Line 3,259:


=={{header|langur}}==
=={{header|langur}}==
<syntaxhighlight lang="langur">val .ispal = fn .s: len(.s) > 0 and .s == reverse .s
<syntaxhighlight lang="langur">
val ispal = fn s:len(s) > 0 and s == reverse(s)


val .tests = {
val tests = {
"": false,
"": false,
"z": true,
"z": true,
Line 3,278: Line 3,279:
}
}


for .word in sort(keys .tests) {
for word in sort(keys(tests)) {
val .foundpal = .ispal(.word)
val foundpal = ispal(word)
writeln .word, ": ", .foundpal, if(.foundpal == .tests[.word]: ""; " (FAILED TEST)")
writeln word, ": ", foundpal, if(foundpal == tests[word]: ""; " (FAILED TEST)")
}
}</syntaxhighlight>
</syntaxhighlight>


{{out}}
{{out}}