[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Elisp function that performs numeric computations
From: |
fatiparty |
Subject: |
Elisp function that performs numeric computations |
Date: |
Fri, 21 Jan 2022 10:04:48 +0100 (CET) |
Jan 21, 2022, 10:53 by sorganov@gmail.com:
> fatiparty--- via Users list for the GNU Emacs text editor
> <help-gnu-emacs@gnu.org> writes:
>
>> Jan 19, 2022, 23:29 by mbork@mbork.pl:
>>
>>>
>>> (defun test (depth maxdepth rptdepth)
>>>
>>>> "Compute depth to use."
>>>> (interactive)
>>>>
>>>> (let* ( (j rptdepth)
>>>> (w (- maxdepth j))
>>>> (p (+ w 1))
>>>> (r (mod (- depth maxdepth 1) p) )
>>>> (o (+ j r)) )
>>>> o))
>>>>
>> I would like to adapt the function a little bit more. If depth <= maxdepth
>> I want to set o=depth instead of performing the computation shown for the
>> variable o.
>>
>
> Did I get it right, I wonder?
>
> (defun test (depth maxdepth rptdepth)
> (if (<= depth maxdepth)
> depth
> (+ rptdepth
> (mod (- depth maxdepth 1)
> (- maxdepth rptdepth -1)))))
>
> Is it how true (E)Lisp'er would write it?
> -- Sergey Organov
>
I have done as follows, which seems to be working correctly.
(defun test (dcur dmax drpt)
"Compute brace depth used for brace colouring."
(interactive)
(if (<= dcur dmax)
(let ( (n dcur) )
(message "dcur <= dmax | Typeface: %d" n)
n)
(let* ( (j drpt)
(w (- dmax j))
(p (+ w 1))
(r (mod (- dcur dmax 1) p) )
(n (+ j r)) )
(message "dcur > dmax | Typeface: %d" n)
n) ))
- Elisp function that performs numeric computations, (continued)
- Message not available
- Elisp function that performs numeric computations, fatiparty, 2022/01/19
- Re: Elisp function that performs numeric computations, tomas, 2022/01/19
- Re: Elisp function that performs numeric computations, Marcin Borkowski, 2022/01/19
- Elisp function that performs numeric computations, fatiparty, 2022/01/19
- Re: Elisp function that performs numeric computations, Sergey Organov, 2022/01/20
- Elisp function that performs numeric computations, fatiparty, 2022/01/21
- Re: Elisp function that performs numeric computations, Emanuel Berg, 2022/01/21
- Re: Elisp function that performs numeric computations, Sergey Organov, 2022/01/21
- Re: Elisp function that performs numeric computations, Emanuel Berg, 2022/01/21
- Re: Elisp function that performs numeric computations, Sergey Organov, 2022/01/21
- Elisp function that performs numeric computations,
fatiparty <=
- Re: Elisp function that performs numeric computations, Emanuel Berg, 2022/01/21
- Elisp function that performs numeric computations, fatiparty, 2022/01/21
- Message not available
- Elisp function that performs numeric computations, fatiparty, 2022/01/20
- Re: Elisp function that performs numeric computations, Manuel Giraud, 2022/01/19
- Re: Elisp function that performs numeric computations, Eduardo Ochs, 2022/01/19
Re: Elisp function that performs numeric computations, Michael Heerdegen, 2022/01/19