Subject: Re: ITERATE vs LOOP - Popular opinion observation?
From: (Rob Warnock)
Date: Fri, 04 Aug 2006 02:42:46 -0500
Newsgroups: comp.lang.lisp
Message-ID: <>
Lars Brinkhoff  <> wrote:
| I think I would like to rearrange the logic slightly:
|   (defun decode-bits (n)
|     (cond
|       ((eql n -1) '(all-ones))
|       ((minusp n) (cons 'all-ones-except (decode-bits (lognot n))))
|       (t
|        (loop for i downfrom (integer-length n) to 0
|              when (logbitp i n)
|                collect i))))

Yeah, that is much cleaner, thanks!!

| > Would a MAPxxx version be more readable?
| Starting from this later version, and assuming some kind of MAP-BITS
| function, I don't think it would too bad.

Well, the guts of it is still the LOOP...WHEN...COLLECT idiom,
and that's going to need a hairy MAPCAN or something to get
equivalent behavior. Not to mention that COLLECT is generally much
more efficient that the (REVERSE (DOxxx ... (WHEN ... (PUSH ...))))


Rob Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607