[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Run terminal command with output in current buffer
From: |
Stefan Monnier |
Subject: |
Re: Run terminal command with output in current buffer |
Date: |
Mon, 19 Jul 2021 00:49:51 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Emanuel Berg via Users list for the GNU Emacs text editor [2021-07-19 02:42:44]
wrote:
> 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?
AFAICT in your case you do want the variable(s) to contain different values
at different times.
> 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 - ?)
`setf` and `setq` are basically the same thing here.
BTW, if you really do want to avoid `setq` (and hence `setf` as well),
you can of course do it, using recursion:
(defun binary-search (value array)
(cl-labels ((loop (low high)
(let ((middle (floor (+ low high) 2)))
(cond ((> (aref array middle) value)
(loop low (1- middle)))
((< (aref array middle) value)
(loop (1+ middle) high))
(t (cl-return middle))))))
(loop 0 (1- (length array)))))
-- Stefan
- Re: ‘read-string’ over ‘read-from-minibuffer’, (continued)
- 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, 2021/07/18
- Re: Run terminal command with output in current buffer,
Stefan Monnier <=
- 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