emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inverse of add-to-list: remove-from-list


From: Boruch Baum
Subject: Re: inverse of add-to-list: remove-from-list
Date: Tue, 13 Oct 2020 16:07:18 -0400
User-agent: NeoMutt/20180716

On 2020-10-13 22:01, Andreas Schwab wrote:
> On Okt 13 2020, Boruch Baum wrote:
>
> >> On Okt 13 2020, Uwe Brauer wrote:
> >> > But there is, as far as I know, no inverse functionality
> >
> > 1] Similar to what Andreas suggested, try this:
> >
> >      (let ((aa '(1 2 3 1 4 1 2)))
> >        (delete 2 aa)
> >        aa)
> >
> >    And note that the fine distinction made in the docstring for the
> >    `delete' function:
> >
> >      "If SEQ is not a list, deletion is never performed destructively;
> >       instead this function creates and returns a new vector or string.
> >
> >       Write ‘(setq foo (delete element foo))’ to be sure of correctly
> >       changing the value of a sequence ‘foo’.
> >
> >    So, in the case of SEQ being a list, there is no need to `setq foo'.
>
> This is not true.

Oops. You're correct...

>  If the element to delete is the first element of the list, it returns
> the cdr of the list.

... but to quibble, that's not exactly what I'm getting

  (let ((aa '(1 2 3 1 4 1 2)))
    (delete 1 aa)
    aa)

returns (1 2 3 4 2), so it seems to destructively modify the cdr of the
list.

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]