[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Appending lists
From: |
Jean Louis |
Subject: |
Re: Appending lists |
Date: |
Wed, 16 Jun 2021 12:13:21 +0300 |
User-agent: |
Mutt/2.0.7+183 (3d24855) (2021-05-28) |
* tomas@tuxteam.de <tomas@tuxteam.de> [2021-06-16 10:29]:
> On Wed, Jun 16, 2021 at 03:11:43AM +0200, Emanuel Berg via Users list for the
> GNU Emacs text editor wrote:
> > tomas wrote:
> >
> > > (setq thing (copy-sequence '(one two three four five six)))
> > > (setq thang (cddr thing))
> > >
> > > thang => (three four five six)
> > >
> > > (nreverse thing) => (six five four three two one)
> > >
> > > thing => (one)
> > >
> > > thang => (three two one)
> > > ; now this is what I was after. Who the heck "changed my
> > > ; variable!?" Who is General Failure and why is he reading
> > > ; my disk?
> >
> > Well, let's see, `nreverse' has updated the data without
> > setting the variables to whatever desired values they should
> > take
>
> It can't. It's a function.
>
> Doing (foo x y) will *never* change "the variable x" -- unless
> foo is a macro/special form.
(setq list-1 '(1 2 3))
(setq list-2 '(A B))
(nconc list-1 list-2) ⇒ (1 2 3 A B)
list-1 ⇒ (1 2 3 A B)
nconc is a built-in function in ‘C source code’.
So it obviously changes the variable `list-1' from (1 2 3) to (1 2 3 A
B) -- how do you explain that?
So far I know from Common Lisp those functions starting with "n" are
common with side effects.
(nreverse list-1) ⇒ (B A 3 2 1)
list-1 ⇒ (1) ⁈⁈⁈⁈⁈⁈⁈⁈⁈⁈⁈
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
- Re: Appending lists, (continued)
- Re: Appending lists, Pierpaolo Bernardi, 2021/06/14
- Re: Appending lists, Pierpaolo Bernardi, 2021/06/14
- Appending lists, henri-biard, 2021/06/14
- Re: Appending lists, Alexandr Vityazev, 2021/06/14
- Re: Appending lists, Emanuel Berg, 2021/06/14
- Re: Appending lists, Emanuel Berg, 2021/06/15
- Re: Appending lists, tomas, 2021/06/15
- Re: Appending lists, Emanuel Berg, 2021/06/15
- Re: Appending lists, tomas, 2021/06/16
- Re: Appending lists,
Jean Louis <=
- Re: Appending lists, tomas, 2021/06/16
- Re: Appending lists, Jean Louis, 2021/06/16
- Re: Appending lists, Emanuel Berg, 2021/06/16
- Using Emacs for business, Jean Louis, 2021/06/16
- Re: Using Emacs for business, Emanuel Berg, 2021/06/16
- Re: Using Emacs for business, Jean Louis, 2021/06/16
- Re: Using Emacs for business, Emanuel Berg, 2021/06/16
- Re: Using Emacs for business, Jean Louis, 2021/06/17
- Re: Appending lists, Jean Louis, 2021/06/16
- Re: Appending lists, tomas, 2021/06/16