Course of Raku / Addendum 🆕 / Working with data / Text and strings / Exercises / Palindrome check
Solution: Palindrome check
Here is a possible solution to the task.
Code
for <level hello racecar> -> $word {
say "$word: { $word eq $word.flip ?? 'yes' !! 'no' }";
}🦋 You can find the source code in the file palindrome.raku.
Output
level: yes
hello: no
racecar: yesComments
.flipreverses the characters of a string. A word is a palindrome exactly when it equals its own reverse, which the ternary turns intoyesorno.