Subject: Re: Char ordering.
From: Erik Naggum <erik@naggum.net>
Date: Fri, 08 Mar 2002 16:47:57 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3224594886419204@naggum.net>

* Jacek Generowicz <jacek.generowicz@cern.ch>
| I want to write a function which converts the letters a-z (lower or
| uppercase) to the integer 0; f,g,h,j,k (note absence of i) to the
| integer 1; l-p to 2; q-u to 3 and v-z to 4.
| 
| Ignoring the annoyance of the missing i, a floor operation, and an
| upcase, this boils down to mapping the letters to consecutive numbers.

  Huh?

| The spec tells me that partial ordering of characters is guaranteed, but
| points out that contiguity is not.

  So?  Who cares?

| How should I go about writing this function in an implementation
| independent way ?

(case (char-upcase char)
  ((#\A #\B #\C #\D #\E) 0)
  ((#\F #\G #\H #\J #\K) 1)
  ((#\l #\m #\n #\o #\p) 2)
  ((#\Q #\R #\S #\T #\U) 3)
  ((#\V #\W #\X #\Y #\Z) 4))

///
-- 
  In a fight against something, the fight has value, victory has none.
  In a fight for something, the fight is a loss, victory merely relief.