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

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

Re: cl-dolist, dolist, cl-return,


From: Emanuel Berg
Subject: Re: cl-dolist, dolist, cl-return,
Date: Thu, 09 Jul 2015 01:19:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> No, of course I don't want to re-evaluate it!
>
> My point was that the re-evaluation part would be
> just a side-problem: even if your expression is
> a mere variable (so re-evaluating it is very cheap),
> the need to use `nth' at each step would force an
> O(N^2) complexity to this loop.

You mean `nth' is linear, and `dotimes' is linear, so
the whole thing is linear**2 = quadratic?

But I'm not using nth - probably you misread "neq".
(Ha! - maybe a reason not to do it just presented
itself...)

Here is the code, which is linear, O(n), unless
there is a hidden nth somewhere...

(defun neq (a b)
  (not (eq a b) ))

(defun erc-kill-buffer-stay ()
  "Close the current ERC buffer (e.g., to leave a channel)
but stay in ERC if possible."
  (interactive)
  (cl-loop for b in (erc-buffer-list)
           when (neq b (current-buffer)) do
           (erc-cmd-LEAVE "")
           (switch-to-buffer b) ))

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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