From ... Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!news-hub.siol.net!newsfeed.Austria.EU.net!newsfeed.kpnqwest.at!nslave.kpnqwest.net!nloc.kpnqwest.net!nmaster.kpnqwest.net!nreader1.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: Char ordering. References: <3224594886419204@naggum.net> <3C886F6D.6AF79FEE@hotmail.com> <3C8A29EB.C1292D7E@hotmail.com> Mail-Copies-To: never From: Erik Naggum Message-ID: <3224754202619544@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 45 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 10 Mar 2002 13:03:13 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader1.kpnqwest.net 1015765393 193.71.199.50 (Sun, 10 Mar 2002 14:03:13 MET) NNTP-Posting-Date: Sun, 10 Mar 2002 14:03:13 MET Xref: archiver1.google.com comp.lang.lisp:28348 * Jacek Generowicz | I still would be interested to find a built in way of mapping the letters | to their positions, though from previous posts I infer that I am unlikely | to find one. I find your lack of faith disturbing. In the interest of not having Common Lisp portrayed as thw feeble-minded language you portray it to be, I offer a solution for the public interest, not particularly for you. I would prefer if you did not use it, but instead reinvented this badly. (- (digit-char-p 36) 10) returns the numeric value of a character in base 36, which has value 10 for #\A and 35 for #\Z, minus the obvious 10, to get the position of the character. It works in both cases. Note that digit-char-p is probably using a table lookup, so you cannot trust it. (digit-char (+ 10 weight) 36) likewise returns the letter of the alphabet corresponding to its position in our basic alphabet, and the easiest solution here, too, is a table lookup, so you cannot trust these solutions at all. Note that the mess that is created by #\i is actually best left to a table regardless of your highly irrational fear of tables. My suggested solution of using case may be created with a macro if you really, really have to see code that is harder to read and prove correct than a simple table, but know that a case that has only simple constants and values would be turned into a table lookup by any reasonably smart compiler. Consider, for instance, the same typo in (range #\l #\p) as in its value -- would it be any _less_ error-prone or hard to catch? Considering that you did catch the table error immediately, but have not been able to find your way in the hyperspec for a simple mapping from character to digit, I think you would trust the code just as blindly and irrationally as you do _not_ trust the tables. Irrationalities of your kind betray a larger and more fundamental problem with dealing with human fallibility, of which I think we have seen quite enough. Please express your gratitude in style with your bogus "resolution". /// -- 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.