help-gnu-emacs
[Top][All Lists]
Advanced

[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: Emanuel Berg
Subject: Re: Easy to add with push but not to the end of a list
Date: Wed, 30 Nov 2022 17:12:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

tomas wrote:

>>> Add them in the reverse order and finish with a simple
>>> `reverse`. That's a very standard design pattern with
>>> singly-linked lists (and in many/most cases the final
>>> `reverse` can be an `nreverse`).
>> 
>> I thought about `nreverse' but if that changes all the CDRs
>> then that's linear as well i.e. O(n), otherwise you could
>> do nreverse, `push', and nreverse again ...
>
> The pattern is push, push, push, push... nreverse.

And the `push' after that?

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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