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: Drew Adams
Subject: RE: [External] : Re: Easy to add with push but not to the end of a list
Date: Mon, 28 Nov 2022 21:56:48 +0000

> 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.



reply via email to

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