Subject: Re: ITERATE vs LOOP - Popular opinion observation?
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 04 Aug 2006 02:42:46 -0500
Newsgroups: comp.lang.lisp
Message-ID: <QZGdnZ01p4zrZ0_ZnZ2dnUVZ_tqdnZ2d@speakeasy.net>
Lars Brinkhoff  <lars.spam@nocrew.org> 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 ...))))
idiom.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607