Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!bu-cs!bloom-beacon!apple!bbn!gateway!dsys.icst.nbs.GOV!rbj From: rbj@dsys.icst.nbs.GOV (Root Boy Jim) Newsgroups: comp.emacs Subject: Postscript eexec tools in GNU Emacs (nits and picks) Message-ID: <8905050031.AA07824@dsys.icst.nbs.gov> Date: 5 May 89 00:31:23 GMT Sender: news@bbn.COM Organization: National Institute of Standards and Technology formerly National Bureau of Standards Lines: 62 ? Reply-To: "Randal L. Schwartz @ Stonehenge" ? (defun byte-to-hex-string (byte) ? "Convert BYTE to a string by printing it in hexadecimal." ? ;; quick and dirty ? (concat (char-to-string (aref "0123456789abcdef" (logand 15 (lsh byte -4)))) ? (char-to-string (aref "0123456789abcdef" (logand 15 byte))))) The above function can be written as: (defun byte-to-hex-string (byte) "mumble" (format "%x" byte)) Unfortunately, the reverse is not true. String-to-int should also take an optional base argument. Having said that, I will now quibble with your input scanner: (defun hex-string-to-int (str) "Convert STRING to an integer by parsing it as a hexadecimal number." (let ((result 0) ch) (while (string-match "^[0-9a-fA-F]" str) (setq ch (string-to-char (substring str 0 1)) str (substring str 1) result (+ (* 16 result) (cond ((>= ch ?a) (+ (- ch ?a) 10)) ((>= ch ?A) (+ (- ch ?A) 10)) (t (- ch ?0)))))) result)) Replace (string-to-char (substring str 0 1)) with (aref str 0). A string is really a vector of characters; you used this fact later. You can always replace (* 16 result) with (lsh result 4). Since you have already verified that the digits match [0-9a-fA-F], you can replace the cond statement with: (logand 15 (+ ch (if (> ch ?9) 9 0))) Finally, towards the end you wrote ... (concat (mapcar ... )) ... I'm not sure, but this looks awful similar to ... (mapconcat ...) ... BTW, to the author of SIP (scroll-in-place): you wrote a function whose point was to determine if two numbers were of same sign. The definition looked something like: (defun same-sign (x y) "Return t is X and Y are same sign, else nil" (if (< x 0) (< y 0) (<= 0 y))) How bout: (defun same-sign (x y) (<= 0 (logxor x y))) instead? You could also use `natnump' instead of `<='. If the function was different-sign, then replace `<=' with `>'. Don't y'all just hate smart alecks :-? Root Boy Jim is what I am Are you what you are or what?