Palindrome detection: Difference between revisions

→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details
(→‎{{header|Rust}}: Add unicode grapheme solution)
(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
Line 1,813:
 
=={{header|Kotlin}}==
<lang scala>// version 1.01.62
 
/* These functions deal automatically with Unicode as all strings are UTF-16 encoded in Kotlin */
 
fun isExactPalindrome(s: String) = (s == s.reversed())
 
fun isInexactPalindrome(s: String): Boolean {
Line 1,828:
fun main(args: Array<String>) {
val candidates = arrayOf("rotor", "rosetta", "step on no pets", "été")
for (candidate in candidates) {
println("'$candidate' is ${if (isExactPalindrome(candidate)) "an" else "not an"} exact palindrome")
}
println()
val candidates2 = arrayOf(
Line 1,836 ⟶ 1,837:
"A man, a plan, a canal - Panama!",
"Ce repère, Perec" // note: 'è' considered a distinct character from 'e'
)
for (candidate in candidates2) {
println("'$candidate' is ${if (isInexactPalindrome(candidate)) "an" else "not an"} inexact palindrome")
}
}
}</lang>
 
{{out}}