Subject: Re: recursive function that returns true/false (newbie stuff)
From: Erik Naggum <clerik@naggum.no>
Date: 1998/01/26
Newsgroups: comp.lang.lisp
Message-ID: <3094764034583296@naggum.no>


* Kevin Goodier
| I for some reason assumed that the comparison had to be performed
| character by character.

  yes, that is of course true.

| If I understand correctly, EQUAL is the only equality operator that will
| work in this case?

  well, no, if this is a string (REVERSE works on strings, no need to use a
  list), you have a choice of EQUAL, EQUALP, STRING=, and STRING-EQUAL.

| Efficiently is not a concern for this particular problem, but one thing
| that could help would be to check if the list length is odd.  If so, it
| isn't a palindrome.

  a palindrome is a word (or phrase) that reads the same either way.
  often, a phrase is considered palindromatic if the letters used are the
  same either way, regardless of interspersed punctuation.  Guy L. Steele
  in Common Lisp the Language, 2nd edition, had great fun with a longer
  version of a traditional palindrome one (thanks to Digital Press for
  releasing the sources):

 "A man, a plan, a canoe, pasta, heros, rajahs, a coloratura, maps, snipe,
  percale, macaroni, a gag, a banana bag, a tan, a tag, a banana bag again
  (or a camel), a crepe, pins, Spam, a rut, a Rolo, cash, a jar, sore hats,
  a peon, a canal--Panama!"

| So, out of curiousity, how would one check for an odd number in LISP?  Is
| there a mod operator?

  yes, but ODDP and EVENP are slightly more intuitive.

#:Erik
-- 
The year "98" was new 1900 years ago.  |  Help fight MULE in GNU Emacs 20!
Be year 2000 compliant, write "1998"!  |  http://sourcery.naggum.no/emacs/