Subject: Re: distinction?
From: Erik Naggum <erik@naggum.net>
Date: 2000/12/04
Newsgroups: comp.lang.lisp
Message-ID: <3184959294361655@naggum.net>

* Dorai Sitaram
| There is a quite antient technique that allows one to
| build up a list left-to-right in one pass, at the
| constant overhead of just a couple of extra conses.

  Only one extra cons, actually.

(do* ((tail (cons nil nil) (cdr tail))
      (head (cdr tail))
      (list <list> (cdr list))
      element)
    ((null list) head)
  (setf element (car list))
  ...
  (setf (cdr tail) (list element)))

| Nobody seems to use it though and it isn't even mentioned in textbooks
| anymore.

  Well, it has naturally become macrofied because it _is_ quite hairy
  and intrusive to write manually every time.  Software patterns
  notwithstanding, some things are just better off being macros.

| I think I saw it in an old book by Wilensky or Touretzky?

  I have only seen it explained.  The coding seems to vary according to
  the specific needs of the body of the loop.

#:Erik
-- 
  "When you are having a bad day and it seems like everybody is trying
   to piss you off, remember that it takes 42 muscles to produce a
   frown, but only 4 muscles to work the trigger of a good sniper rifle."
								-- Unknown