let is_palindrome s =
  let n = String.length s in
  let rec check i j =
    if i >= j then true
    else if s.[i] <> s.[j] then false
    else check (i + 1) (j - 1)
  in
  check 0 (n - 1)

;;

(if is_palindrome "racecar" then 1 else 0) +
(if is_palindrome "hello" then 1 else 0) +
(if is_palindrome "abba" then 1 else 0) +
(if is_palindrome "" then 1 else 0) +
(if is_palindrome "a" then 1 else 0) +
(if is_palindrome "ab" then 1 else 0)
