help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: append, push, and add-to-list.


From: Hongyi Zhao
Subject: Re: append, push, and add-to-list.
Date: Mon, 5 Jul 2021 14:22:17 +0800

On Mon, Jul 5, 2021 at 1:11 PM Jean Louis <bugs@gnu.support> wrote:
>
> * Hongyi Zhao <hongyi.zhao@gmail.com> [2021-07-05 05:17]:
> > On Mon, Jul 5, 2021 at 12:19 AM Emanuel Berg via Users list for the
> > GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> > >
> > > Hongyi Zhao wrote:
> > >
> > > > I've noticed there are some similar functions, i.e., append,
> > > > push, and add-to-list, for revising/updating the content of
> > > > a list. But I'm still not so clear on the specific use
> > > > scenarios for them. Consider the following command [1]
> > >
> > > `nconc', `cl-pushnew', (setq lst `(,@lst el)) ...
> >
> > Does the following append `el' to `lst'?
> >
>
> (defvar lst '()) ⇒ lst
>

(equal '() nil)
t

So, I would rather write it like this:

(defvar lst nil)

HY

> (setq lst `(,@lst el)) ⇒ (el)
>
> lst  ⇒ (el)
>
> I see it does when variable `list' is defined in advance.
>
> --
> Jean
>
> Take action in Free Software Foundation campaigns:
> https://www.fsf.org/campaigns
>
> In support of Richard M. Stallman
> https://stallmansupport.org/



-- 
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
NO. 552 North Gangtie Road, Xingtai, China



reply via email to

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