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

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

Re: Elisp - Function returning a sequence of times


From: Joost Kremers
Subject: Re: Elisp - Function returning a sequence of times
Date: Wed, 16 Dec 2020 10:20:03 +0100
User-agent: mu4e 1.5.7; emacs 27.1.50

On Wed, Dec 16 2020, steve-humphreys@gmx.com wrote:
> I have done something like this, but need help to finalise the actual 
> function.
> Do you agree on this solution?
>
>
> (defun timfutur ()
>    (interactive)
>    (setq tm 845)
>    (setq tsk 30)
>    (setq thr (/ tm 100))
>    (setq tmn (- tm (* thr 100)))
>    (setq tmn-futur (% (+ tmn tsk) 60))
>    (setq thr-futur (% (+ (/ (+ tmn tsk) 60) thr) 24))
>    (message "%d %d %d%d" thr tmn thr-futur tmn-futur))

My humble opinion: try to avoid `setq` at all cost. It has some legitimate uses,
but they're far and few between.

```
(defun timfutur ()
  (interactive)
  (let* ((tm 845)
         (tsk 30)
         (thr (/ tm 100))
         (tmn (- tm (* thr 100)))
         (tmn-futur (% (+ tmn tsk) 60))
         (thr-futur (% (+ (/ (+ tmn tsk) 60) thr) 24)))
    (message "%d %d %d%d" thr tmn thr-futur tmn-futur)))
```

-- 
Joost Kremers
Life has its moments



reply via email to

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