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

[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 13:25:55 +0100 (CET)

Jan 21, 2022, 23:51 by help-gnu-emacs@gnu.org:

> fatiparty--- via Users list for the GNU Emacs text editor wrote:
>
>> (defun test (dcur dmax drpt)
>>
>
> All programming: Name the function something that etc etc.
>
> Lisp: We don't name formal parameters the assembly language or
> C style ... give them short, but if possible complete names
> that are easy to read and write. When in doubt, give them
> a complete name that communicates what its purpose or
> intended use.
>
>> "Compute brace depth used for brace colouring."
>>
>
> Doc string should have the formal parameter's names in BOLD in
> the order they come in the the function definition ...
>
>> (interactive)
>>
>
> Assign the formal parameters with argument values
>
> (interactive "ndepth: \nntop: \nnrepeat: ")
>  ^ eval me
>
> Use English in the prompt string, if the words feel to long
> see if they can be shortened in a natural way (here, e.g. dep,
> top, and rep) - the reason one avoids "max" is it also appears
> in as the function `max' ...
>
>> (let ( (n dcur) )
>>  (message "dcur <= dmax | Typeface: %d" n)
>> n)
>>
>
> If there is no computation, renaming it ... why do you
> do that?
>

I did that because I use n an the output (either it is dcur [current depth] or 
it is from the
latter computation).

But as you say, I could just do

(if (<= dcur dmax)      dcur

(let* ( (j drpt) ...



> You use it like this:
>
> (let*((side 2)
>  (square (expt side 2) )) ...
>  ;; use square here
>  )
>
> -- 
> underground experts united
> https://dataswamp.org/~incal
>




reply via email to

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