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

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

RE: [External] : Re: Easy to add with push but not to the end of a list


From: Heime
Subject: RE: [External] : Re: Easy to add with push but not to the end of a list
Date: Mon, 28 Nov 2022 22:18:18 +0000

------- Original Message -------
On Monday, November 28th, 2022 at 9:56 PM, Drew Adams <drew.adams@oracle.com> 
wrote:


> > I agree there should be such a function in vanilla Emacs.
> > Maybe something like this?
> > 
> > (defun push-last (elem lst)
> > (when (listp lst)
> > (setcdr (last lst) (list elem))
> > lst))
> 
> 
> As I said, there are umpteen different meanings /
> behaviors for "add an element to the end of a list".
> 
> (setcdr (last lst) (list elem)) is one such behavior.
> 
> And that's just as succinct as (push-last elem lst),
> and clearer. It makes crystal clear that you're
> opting for list modification.

There are never any qualms about putting something at the beginning 
of a list.  One should not take a different attitude to adding after 
the last entry.




reply via email to

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