generalize is_palindrome with a functional style