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 13:07:56 +0800

On Mon, Jul 5, 2021 at 12:32 PM Emanuel Berg via Users list for the
GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
>
> >> Does the following append `el' to `lst'?
> >>
> >> (setq lst `(,@lst el))
> >
> > Yes, literally, but maybe it makes more sense if that is
> > evaluated as well?
> >
> > (defvar lst)
> > (setq lst '(a b c))
> >
> > (defvar el)
> > (setq el 4)
> >
> > (setq lst `(,@lst ,el))
> >
> > Now "lst" will be (a b c 4)
>
> (setq lst '(a b))
> (setq lst `(,@lst logic) ; (a b logic)
>

You have a typo here, should be the following:

((setq lst `(,@lst logic))

Wonderful examples, but how to eval multiple line lisp codes in
scratch buffer? I only know with twice hitting of `C-j' for this job,
as shown below:

(setq lst '(a b)) <--- C-j
(a b)

((setq lst `(,@lst logic)) <-- C-j
(a b logic)

HY
-- 
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]