[comp.lang.lisp] CL sort functions

pete@edsr.eds.com (Pete Humphrey) (06/16/90)

The Common Lisp definition of the sort function allows it to
destructively modify the sequence, but does it allow it delete items
from the sequence?  For example, is the following behavior in Allegro
Common Lisp a bug?

    <cl> (setq xxx (list '(1 a) '(0 b) '(1 c) '(0 e) '(1 f)))

    ((1 A) (0 B) (1 C) (0 E) (1 F)) 

    <cl> (sort xxx #'< :key #'first)

    ((0 B) (0 E) (1 A) (1 C) (1 F)) 

    <cl> xxx

    ((1 A) (1 C) (1 F)) 

Pete Humphrey
pete@edsr.eds.com
(505) 345-1863

US Mail:
Pete Humphrey
EDS Research
5951 Jefferson Street N.E.
Albuquerque, New Mexico 87109-3432

rar@kronos.ads.com (Bob Riemenschneider) (06/17/90)

I'm not sure anyone will notice, but in my previous response, I left an 
arrow in the "after" figure that should have been deleted.  Here's another
try:



"xxx's
 value 
 cell"
 |
 | -------------------------------------------------
 | |                                               |
 | |               ------------------------------- |
 | |               |                             | |
 | |   ------------+--------------     ----------+-+--------------
 | |   |           |             |     |         | |             |
 v v   |           |             v     |         v |             v
[o|o]---        [o|o]           [o|o]---        [o|o]           [o|/]
 |               |               |               |               |
 |               |               |               |               |
 v               v               v               v               v
[o|o]--->[o|/]  [o|o]--->[o|/]  [o|o]--->[o|/]  [o|o]--->[o|/]  [o|o]--->[o|/]
 |        |      |        |      |        |      |        |      |        |
 |        |      |        |      |        |      |        |      |        |
 v        v      v        v      v        v      v        v      v        v
 1        A      0        B      1        C      0        E      1        F



I'll proofread more carefully next time.  Honest!

							-- rar