Re: sanity check (coding style)
- From: Peter Seibel <peter@xxxxxxxxxxxxxxx>
- Date: Tue, 29 Nov 2005 21:03:12 GMT
tar@xxxxxxxxxxxxx (Thomas A. Russ) writes:
> Christophe Rhodes <csr21@xxxxxxxxx> writes:
>
> (defun digest2string (v)
> (with-output-to-string (s)
> (loop for x across v
> do (format s "~2,'0X" x))))
>
>
> This is nice, since it uses the string stream to collect the values. If
> efficiency is really critical, one could avoid the FORMAT call (which
> often tends to be slow) and subsitute a 256 element lookup table:
>
> (defconstant *hex-codes* #("00" "01" ... "FF"))
Surely we don't have to write that by hand; that's not The Lisp Way!
(defconstant *hex-codes* #.(coerce (loop for i from #x00 to #xff collect (format nil "~2,'0x" i)) 'vector))
;-)
-Peter
--
Peter Seibel * peter@xxxxxxxxxxxxxxx
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp * http://www.gigamonkeys.com/book/
.
- Follow-Ups:
- Re: sanity check (coding style)
- From: Christophe Rhodes
- Re: sanity check (coding style)
- References:
- sanity check (coding style)
- From: Sylvain
- Re: sanity check (coding style)
- From: Christophe Rhodes
- Re: sanity check (coding style)
- From: Thomas A. Russ
- sanity check (coding style)
- Prev by Date: Re: Hints on recursion
- Next by Date: Re: OT to the extreme [Was Re: I'm working on yet another license]
- Previous by thread: Re: sanity check (coding style)
- Next by thread: Re: sanity check (coding style)
- Index(es):
Relevant Pages
|