[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Easy to add with push but not to the end of a list
From: |
Stefan Monnier |
Subject: |
Re: Easy to add with push but not to the end of a list |
Date: |
Mon, 28 Nov 2022 00:18:08 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> 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.
That's because adding to the end of a Lisp list is a *bad* idea.
Your better option usually is to avoid doing that by keeping your list
in reverse order while you add elements to it and to reverse it at the end.
> Would be appreciated if Emacs could have a function as simple
> to add to the end of a list?
(cl-callf PLACE (lambda (xs) (append xs (list VAL))))
while `push` is constant time, the above has O(N) complexity.
Stefan
- Easy to add with push but not to the end of a list, Heime, 2022/11/27
- RE: [External] : Easy to add with push but not to the end of a list, Drew Adams, 2022/11/27
- Re: Easy to add with push but not to the end of a list,
Stefan Monnier <=
- Re: Easy to add with push but not to the end of a list, Emanuel Berg, 2022/11/28
- Re: Easy to add with push but not to the end of a list, Heime, 2022/11/28
- Re: Easy to add with push but not to the end of a list, Stefan Monnier, 2022/11/28
- Re: Easy to add with push but not to the end of a list, Emanuel Berg, 2022/11/30
- Re: Easy to add with push but not to the end of a list, tomas, 2022/11/30
- Re: Easy to add with push but not to the end of a list, tomas, 2022/11/29
- Re: Easy to add with push but not to the end of a list, Heime, 2022/11/29
- Re: Easy to add with push but not to the end of a list, Marcin Borkowski, 2022/11/29