From: Andreas Schwab <schwab@linux-m68k.org>
To: Boruch Baum <boruch_baum@gmx.com>
Cc: Emacs-Devel List <emacs-devel@gnu.org>
Subject: Re: inverse of add-to-list: remove-from-list
Date: Tue, 13 Oct 2020 22:01:18 +0200 [thread overview]
Message-ID: <871ri1x5dd.fsf@igel.home> (raw)
In-Reply-To: <20201013193400.uqm2ng6rgfnsei2w@E15-2016.optimum.net> (Boruch Baum's message of "Tue, 13 Oct 2020 15:34:00 -0400")
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. If the element to delete is the first element of the
list, it returns the cdr of the list.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
next prev parent reply other threads:[~2020-10-13 20:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-13 19:34 inverse of add-to-list: remove-from-list Boruch Baum
2020-10-13 8:42 ` Uwe Brauer
2020-10-13 9:09 ` Andreas Schwab
2020-10-13 9:34 ` Thibaut Verron
2020-10-13 11:24 ` Uwe Brauer
2020-10-13 13:57 ` Stefan Monnier
2020-10-14 5:58 ` Thibaut Verron
2020-10-15 15:28 ` Uwe Brauer
2020-10-15 16:31 ` Stefan Monnier
2020-10-16 11:14 ` Thibaut Verron
2020-10-14 5:28 ` Teemu Likonen
2020-10-13 20:01 ` Andreas Schwab [this message]
2020-10-13 20:07 ` Boruch Baum
2020-10-13 20:41 ` Andreas Schwab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871ri1x5dd.fsf@igel.home \
--to=schwab@linux-m68k.org \
--cc=boruch_baum@gmx.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.