|
From: | Emanuel Berg |
Subject: | Re: Easy to add with push but not to the end of a list |
Date: | Mon, 28 Nov 2022 20:59:31 +0100 |
User-agent: | Gnus/5.13 (Gnus v5.13) |
Heime wrote: > Although it is easy to add to a list using push, it > currently looks hideous to be able to add to the end of > a list. I don't know how it currently looks but I agree there should be such a function in vanilla Emacs. > Would be appreciated if emacs could have a function as > simple to add to the end of a list? Maybe something like this? (defun push-last (elem lst) (when (listp lst) (setcdr (last lst) (list elem)) lst) ) (setq lst '(1 2 3 4)) lst ; (1 2 3 4) (push-last 5 lst) ; (1 2 3 4 5) lst ; (1 2 3 4 5) -- underground experts united https://dataswamp.org/~incal
[Prev in Thread] | Current Thread | [Next in Thread] |