实现回文:例如:“abcdedcba”
def huiwen(str)
  if str.length <= 1
    return true
  elsif str[0] == str[-1]
    huiwen(str[1..-2])
  else
    return false
  end
end
        
      def huiwen str
    0.upto(str.size / 2) {|i| return false if str[i] != str[-(i + 1)]}
    true
end
          def huiwen?(str)
  str =~ /\A(?<a>|.|(?:(?<b>.)\g<a>\k<b+0>))\z/
end
是这样么亲?
0.upto(str.size / 2).all? {|i| str[i] == str[-(i + 1)]}
          松本行弘的程序世界里介绍了一种正则匹配回文的方法 要求 ruby1.9 以上
 \A(?<a>|.|(?:(?<b>.)\g<a>\k<b+0>))\z