mirror of
https://git.sr.ht/~crc_/retroforth
synced 2024-11-16 19:48:56 +01:00
848ba7303b
FossilOrigin-Name: b5feea667d30aac255d1cfca61fed355d438d2ce6021677f1e53af6302b15eee
19 lines
502 B
Text
19 lines
502 B
Text
# rosetta|is-palindrome
|
|
|
|
A palindrome is a phrase which reads the same backward and forward.
|
|
|
|
Write a function or program that checks whether a given sequence of
|
|
characters (or, if you prefer, bytes) is a palindrome.
|
|
|
|
|
|
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.
|
|
|
|
~~~
|
|
:s:palindrome? (s-f)
|
|
[ s:hash ]
|
|
[ s:reverse s:hash ] bi eq? ;
|
|
|
|
'ingirumimusnocteetconsumimurigni s:palindrome?
|
|
~~~
|