Subject: Deleteing from a list

From: [email-masked]
Date: Wed, 22 Mar 1995 14:57:18 GMT

I have just discovered a curious ``feature'' of delete. It seems that
you cannot delete the first item in a list. The value returned is
correct but the list itself is not altered, e.g.

> (setf l (list 'a 'b 'c))
(A B C)
> (delete 'a l)
(B C)
> l
(A B C)
> (delete 'b l)
(A C)
> l
(A C)

I am using an old version of CLISP due to necessity so it may be
a known and fixed bug.

David.

-- 
David Arnold                             ([email-masked])
Dept. Computer Science                   +44 (0)1970-622449
University of Wales,Aberystwyth, Dyfed SY23 3DB, UK.
http://www.dcs.aber.ac.uk/~daa93

---

From: haible (Bruno Haible)
Date: Wed, 5 Apr 95 15:24:29 +0200

David Arnold <[email-masked]> writes about the DELETE function:

> It seems that
> correct but the list itself is not altered

You mean that you have stored the list in a variable and would like the
variable to be automatically updated when you call DELETE. This is not
possible because the DELETE function does not know in which variables
the list has been stored. (Just altering the list structure wouldn't help
in the case when you are deleting the first item of a list of length 1.)

Stop thinking in terms of side-effects, and think of DELETE as a _function_
which _returns_ a list with some elements missing, just like REMOVE, the
only difference between DELETE and REMOVE being that DELETE _may_ reuse
the storage occupied by the argument.

                    Bruno Haible
                    [email-masked]