[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Run terminal command with output in current buffer
From: |
Emanuel Berg |
Subject: |
Re: Run terminal command with output in current buffer |
Date: |
Mon, 19 Jul 2021 02:42:44 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Stefan Monnier via Users list for the GNU Emacs text editor wrote:
> Only use `setq` when you really want that variable to
> contain different values at different times.
How do you do it when you compute a value as part of a loop?
We just saw it with binary-search, so let's use that
as example. OK, so they use `setf', not `setq' (set function,
not set function quote - ?)
That's better, really? Not in that sense at least?
(defun binary-search (value array)
(let ((low 0)
(high (1- (length array))))
(cl-do () ((< high low) nil)
(let ((middle (floor (+ low high) 2)))
(cond ((> (aref array middle) value)
(setf high (1- middle)))
((< (aref array middle) value)
(setf low (1+ middle)))
(t (cl-return middle)))))))
--
underground experts united
https://dataswamp.org/~incal
- Re: ‘read-string’ over ‘read-from-minibuffer’, (continued)
- Re: terminal command with output in current buffer, Felix Dietrich, 2021/07/20
- Re: terminal command with output in current buffer, Yuri Khan, 2021/07/20
- terminal command with output in current buffer, lisa-asket, 2021/07/20
- Re: Run terminal command with output in current buffer, Stefan Monnier, 2021/07/16
- Run terminal command with output in current buffer, lisa-asket, 2021/07/16
- Re: Run terminal command with output in current buffer, Stefan Monnier, 2021/07/16
- Run terminal command with output in current buffer, lisa-asket, 2021/07/16
- Run terminal command with output in current buffer, lisa-asket, 2021/07/16
- Re: Run terminal command with output in current buffer,
Emanuel Berg <=
- Re: Run terminal command with output in current buffer, Stefan Monnier, 2021/07/19
- Re: Run terminal command with output in current buffer, Emanuel Berg, 2021/07/19
- Run terminal command with output in current buffer, lisa-asket, 2021/07/16
- Re: Run terminal command with output in current buffer, Felix Dietrich, 2021/07/16
Re: Run terminal command with output in current buffer, Emanuel Berg, 2021/07/16