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

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

Re: Elisp function that performs numeric computations


From: Sergey Organov
Subject: Re: Elisp function that performs numeric computations
Date: Fri, 21 Jan 2022 01:53:49 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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




reply via email to

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