Re: sanity check (coding style)
- From: Pascal Bourguignon <spam@xxxxxxxxxxxxxxxx>
- Date: Tue, 29 Nov 2005 15:02:47 +0100
Christophe Rhodes <csr21@xxxxxxxxx> writes:
> Michael Naunton <mmn@xxxxxxxxxxxxxxxxxxxxx> writes:
>
>> * (defun to-hex-str (ar)
>> (format nil "~x" (reduce (lambda (a b) (+ (* a 256) b)) ar)))
>>
>> * (to-hex-str #(130 154 235 231 1 41 183 140 144 245))
>>
>> "829AEBE70129B78C90F5"
>
> This is going to look a bit petty, but your function gets the string
> wrong in one sixteenth of the cases, when the first element is less
> than 16 (and so the first hex digit is 0).
Slightly more often than that.
(to-hex-str #(0 0 0 0 0 1 2)) --> "102"
--
__Pascal Bourguignon__ http://www.informatimago.com/
.
- 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: Michael Naunton
- Re: sanity check (coding style)
- From: Christophe Rhodes
- sanity check (coding style)
- Prev by Date: Re: How can I sort symbols in alphabetical order?
- Next by Date: Re: sanity check (coding style)
- Previous by thread: Re: sanity check (coding style)
- Next by thread: Re: sanity check (coding style)
- Index(es):
Relevant Pages
|
|