Subject: Re: How to reverse a list...
From: Erik Naggum <erik@naggum.net>
Date: Tue, 04 Dec 2001 17:29:56 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3216475795291629@naggum.net>

* Erik Naggum
>   Traversing a vector is not particularly hard, either:
> 
> (do ((forward 0 (1+ forward))
>      (backward (1- (length vector)) (1- backward))
>      (reversed (copy-seq sequence)))
>     ((minusp backward) reversed)
>   (setf (aref reversed backward) (aref reversed forward)))

* Wolfhard Buß
| Probably
| 
|  (do ((forward 0 (1+ forward))
|       (backward (1- (length sequence)) (1- backward))
|       (reversed (copy-seq sequence)))
|      ((<= backward forward) reversed)
|    (rotatef (aref reversed backward) (aref reversed forward))))
| 
| comes close to your intentions.

  That's a good variation.  What I intended was actually to use
  (aref sequence forward), but it got mixed up somehow.

///
-- 
  The past is not more important than the future, despite what your culture
  has taught you.  Your future observations, conclusions, and beliefs are
  more important to you than those in your past ever will be.  The world is
  changing so fast the balance between the past and the future has shifted.