[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [External] : Easy to add with push but not to the end of a list
From: |
Drew Adams |
Subject: |
RE: [External] : Easy to add with push but not to the end of a list |
Date: |
Mon, 28 Nov 2022 06:11:47 +0000 |
> > > 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. Would be appreciated if emacs could have a
> > > function as simple to add to the end of a list?
> >
> > `add-to-list' with optional arg APPEND?
>
> The problem is that add-to-list enforces uniqueness. Thusly, add-to-list
> is not an actual append, but a constrained append.
In addition to what Stefan said - Lisp lists
favor access/changes at the head, and it's often
better to avoid list traversal, for performance
- which is the main message...
`add-to-list' also accepts an optional predicate
arg to test equality. Passing it a predicate
that returns nil makes it just add.
Not that you have to use `add-to-list'. There
are any number of ways to add something to the
end of a list, if you need to. `add-to-list'
just happens to be one way that you have OOTB.
`append' is another: (append x (list y)). And
`nconc'.
But again, don't work at the end of a list if
you can work at the front, and you can often
do that and just reverse at the end (traverse
the full list only once).
- 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, 2022/11/28
- 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