;;; wordgames.mhtml: -*- Meta-HTML -*-  Some games with words and letters!
;;;
;;; Copyright (c) 1999 Brian J. Fox
;;; Author: Brian J. Fox (bfox@ai.mit.edu) Sun Mar 14 20:13:22 1999.

<defun backwords thing>
  ;;; Return THING spelled backwards.
  <string-to-array <get-var-once thing> characters>
  <array-reverse characters>
  <subst-in-string 
   <subst-in-string <get-var-once characters[]> "\n\n" "-NEWLINE-" "\n" "">
   "-NEWLINE-" "\n">
</defun>

<defun palindrome? thing>
  ;;; Returns "true" if THING is the same spelled backwards as it is spelled
  ;;; forwards.
  <set-var bthing = <downcase <backwords <get-var-once thing>>>>
  <set-var thing = <downcase <get-var-once thing>>>
  <subst-in-var bthing "[^a-z]+" "">
  <subst-in-var thing "[^a-z]+" "">
  <string-eq <get-var-once thing> <get-var-once bthing>>
</defun>
