previous | index | next

Application of reverse: Palindromes

A palindrome is a word or sentence that reads the same reversed. Example:
          Madam, I'm Adam.
Note that punctuation and character case are ignored.

Desired behavior:

          (palindrome? '(m a d a m i m a d a m)) ⇒ #t

          (palindrome? '(m a d a m i m f r e d)) ⇒ #f
Note that characters are represented as names in a list.
     (define palindrome?
       (lambda (lst)
         (equal? lst (reverse lst))))

previous | index | next