RosettaCodeData/Task/Palindrome-detection/Ruby/palindrome-detection-2.rb

10 lines
126 B
Ruby
Raw Permalink Normal View History

2015-02-20 00:35:01 -05:00
def r_palindrome?(s)
2013-04-10 23:57:08 -07:00
if s.length <= 1
true
elsif s[0] != s[-1]
false
else
2015-02-20 00:35:01 -05:00
r_palindrome?(s[1..-2])
2013-04-10 23:57:08 -07:00
end
end