From: Kenneth D. Forbus

Subject: Re: configuring the internal pretty-printer

Date: 1998-6-12 11:51

Actually, yes, I prefer the DO version.  Less to remember than keywords like "never".  Admittedly, it is easier to go wrong with DO.

At 02:08 PM 6/12/98 GMT, Juanma Barranquero wrote:
>-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >On Thu, 11 Jun 1998 10:23:51 -0500, "Kenneth D. Forbus" <ils.nwu.edu at ><forbus> wrote: >
>>Maybe I'm old-fashioned, but I find DO -- which is part of the common >>lisp spec -- is just as easy to use, is more flexible, and displays >>well under pretty-printing.
> >Do you prefer > > (defun primes (n) > (when (> n 1) > (let* ((primes (list 2)) > (last primes) > (max (floor (sqrt n)))) > (do ((i 3 (+ i 2))) > ((> i n) primes) > (do* ((next primes (rest next))) > ((or (null next) > (> (first next) max)) > (rplacd last (list i)) > (setq last (rest last))) > (when (zerop (rem i (first next))) > (return))))))) > >over > > (defun primes (n) > (when (> n 1) > (loop > with primes = (list 2) > with max = (floor (sqrt n)) > with last = primes > for i from 3 to n by 2 > do (loop > for p in primes > until (> p max) > never (zerop (rem i p)) > finally > (rplacd last (list i)) > (setq last (rest last))) > finally (return primes)))) > >then? > >Curiously, in ACL4W 3.0.2, with '(optimize (speed 0) (safety 3)) the >second version is about 10% slower than the first; and with >speed3/safety0 they are 'bout the same. > >(Yes, I admit neither one is a good example of lisp programming; >I'm just learning my way into CL ;) > > > /L/e/k/t/u > > > > >-----BEGIN PGP SIGNATURE----- >Version: PGPfreeware 5.5.3i; see <http://www.pgpi.com> > >iQA/AwUBNYEoO/4C0a0jUw5YEQLbtwCgw6D6AikuucrSz6H1h65uwWei+U0AoIQI >oWPg4KHgWMLXl9Mo2/cADjwy >=0lOg >-----END PGP SIGNATURE----- > > >