[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
- cl-dolist, dolist, cl-return,, Emanuel Berg, 2015/07/07
- Re: cl-dolist, dolist, cl-return,, John Mastro, 2015/07/07
- Re: cl-dolist, dolist, cl-return,, Stefan Monnier, 2015/07/07
- Re: cl-dolist, dolist, cl-return,, Emanuel Berg, 2015/07/08
- Re: cl-dolist, dolist, cl-return,, Stefan Monnier, 2015/07/08
- Re: cl-dolist, dolist, cl-return,,
Emanuel Berg <=
- Re: cl-dolist, dolist, cl-return,, John Mastro, 2015/07/08
- Re: cl-dolist, dolist, cl-return,, Emanuel Berg, 2015/07/09
- Message not available
- Re: cl-dolist, dolist, cl-return,, Barry Margolin, 2015/07/10
- Re: cl-dolist, dolist, cl-return,, Emanuel Berg, 2015/07/11
- Re: cl-dolist, dolist, cl-return,, Stefan Monnier, 2015/07/10
Re: cl-dolist, dolist, cl-return,, Emanuel Berg, 2015/07/08
- Re: cl-dolist, dolist, cl-return,, Pascal J. Bourguignon, 2015/07/07
- Re: cl-dolist, dolist, cl-return,, Emanuel Berg, 2015/07/08
- RE: cl-dolist, dolist, cl-return,, Drew Adams, 2015/07/08
- Re: cl-dolist, dolist, cl-return,, Emanuel Berg, 2015/07/08