e549b4ced6
FossilOrigin-Name: dfed0de00b8d63672a882b79c4951cce0076007ef208c063b2f4e54fe9bd08f8
18 lines
501 B
Forth
18 lines
501 B
Forth
# 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)
|
|
dup s:hash [ s:reverse s:hash ] dip eq? ;
|
|
|
|
'ingirumimusnocteetconsumimurigni s:palindrome?
|
|
~~~
|