2017-10-16 18:09:39 +02:00
|
|
|
# rosetta|is-palindrome
|
|
|
|
|
|
|
|
A palindrome is a phrase which reads the same backward and forward.
|
|
|
|
|
2017-10-23 19:15:10 +02:00
|
|
|
Write a function or program that checks whether a given sequence of
|
|
|
|
characters (or, if you prefer, bytes) is a palindrome.
|
2017-10-16 18:09:39 +02:00
|
|
|
|
|
|
|
|
2017-10-23 19:15:10 +02:00
|
|
|
In Retro this is fairly easy. We can use `s:hash` to identify a unique
|
|
|
|
string. So make a copy, take he hash, reverse the copy, get its hash,
|
|
|
|
and compare them.
|
2017-10-16 18:09:39 +02:00
|
|
|
|
2018-04-25 18:57:28 +02:00
|
|
|
~~~
|
2017-10-16 18:09:39 +02:00
|
|
|
:s:palindrome? (s-f)
|
2018-06-20 15:03:22 +02:00
|
|
|
[ s:hash ]
|
|
|
|
[ s:reverse s:hash ] bi eq? ;
|
2017-10-16 18:09:39 +02:00
|
|
|
|
|
|
|
'ingirumimusnocteetconsumimurigni s:palindrome?
|
2018-04-25 18:57:28 +02:00
|
|
|
~~~
|