Closed mmontone closed 9 years ago
The equivalent of:
(let ((l (list :foo))) (rutils.list:appendf l (list :bar)))
Hmm, it's an interesting question. Maybe, implementing something so inefficient and making it seem easy is not a good idea. Do you have a lot of use cases for it?
Well..it appears here and there for me. I often implement it manually, like above, having to append lists. As for the performance, I'm not sure what to do about it. Add a warning in the documentation? It may be that it is not a good idea to include something like this, I don't know, but I think it is fairly common in other languages, isn't it? Append an element to a list destructively.
I'd say that it's common in languages that have lists implemented on top of arrays (like Python).
I guess, adding a warning to the docs should be enough. Care to create a pull request with the utility and tests? (Btw, I'd call it not push-end
but something like tack
or attach
. What do you think?)
Actually, I've just recalled that you can use setf last-elt
for this. It's much neater, isn't it?
El 16 de julio de 2015 4:03:15 GMT-03:00, Vsevolod Dyomkin notifications@github.com escribió:
Actually, I've just recalled that you can use
setf last-elt
for this. It's much neater, isn't it?
Ah. That's a good one!
Reply to this email directly or view it on GitHub: https://github.com/vseloved/rutils/issues/23#issuecomment-121853164
Is there some utility to push some element to the end of a list? Makes sense to implement one?
(let ((l (list :foo))) (push-end :bar l) l) => (:foo :bar)
push-end, push-last, I don't know how to call it.