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

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

Re: Remove last element in a list


From: Barry Margolin
Subject: Re: Remove last element in a list
Date: Tue, 17 Nov 2009 16:26:04 -0500
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article 
<f1412cfb-1d34-40b3-8192-e528d912cc46@e23g2000yqd.googlegroups.com>,
 LanX <lanx.perl@googlemail.com> wrote:

> ----------- M-x ielm
> ELISP> list
> (a b c d e f g h i)
> 
> ELISP> (nbutlast list 1)
> (a b c d e f g h)
> 
> ELISP> list
> (a b c d e f g h)
> -------------
> 
> see  "5.3 Accessing Elements of Lists" in  Elisp-Info
> 
> HTH
>   LanX

ELISP> list
(a)

ELISP> (nbutlast list 1)
nil

ELISP> list
(a)

Moral: always assign the result back to the variable, even when using 
destructive operations, e.g.

ELISP> (setq list (nbutlist list 1))
nil

ELISP> list
nil

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


reply via email to

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