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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reverse pop, return value


From: David Kastrup
Subject: Re: Reverse pop, return value
Date: Tue, 17 Nov 2009 17:53:42 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

LanX <lanx.perl@googlemail.com> writes:

> Hi
>
> I tried to realize a reverse pop which pops from the end of the list,
> but the code get's "lengthy"....

Don't do that.  If you really need to process the list in reverse order,
_first_ reverse it, then process it from the front.

Reversing is O(n), popping from the front O(1), so working off the whole
list is O(n).  Popping from the end is O(n), making work on the whole
list O(n^2).

-- 
David Kastrup


reply via email to

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