Subject: Re: Char ordering. From: Erik Naggum <firstname.lastname@example.org> Date: Sun, 10 Mar 2002 13:03:13 GMT Newsgroups: comp.lang.lisp Message-ID: <email@example.com> * 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 <char> 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.