[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Understanding the "let" construct and the setting of variables
From: |
Joost Kremers |
Subject: |
Re: Understanding the "let" construct and the setting of variables |
Date: |
Thu, 17 Dec 2020 02:05:27 +0100 |
User-agent: |
mu4e 1.5.7; emacs 27.1.50 |
On Thu, Dec 17 2020, steve-humphreys@gmx.com wrote:
> For example, the following fails. Why? Haw can one fix the function?
>
> (defun lett (tim tsk)
>
> (let* ( (thr (/ tim 100))
> (tmn (- tim (* thr 100)))
>
> (tinc_mn (+ tmn tsk))
> (tinc_hr (/ (+ tmn tsk) 60))
> (tinc_mn (- tinc_mn (* tinc_hr 60)))
>
> (thr_futur (* (+ thr tinc_hr) 100))
> (tmn_futur tinc_mn)
> (tim_out (+ thr_futur tmn_futur))
>
> (message "%d %d" tim_out) )
>
> (message "%s" "lett") ))
>
> (lett 845 80)
The error is a bit cryptic, but it's telling you that you need to move the first
`message` into the body of the `let*`. Right now, it's in the list of variables
to bind, but it's not a valid binding form:
```
(defun lett (tim tsk)
(let* ((thr (/ tim 100))
(tmn (- tim (* thr 100)))
(tinc_mn (+ tmn tsk))
(tinc_hr (/ (+ tmn tsk) 60))
(tinc_mn (- tinc_mn (* tinc_hr 60)))
(thr_futur (* (+ thr tinc_hr) 100))
(tmn_futur tinc_mn)
(tim_out (+ thr_futur tmn_futur)))
(message "%d %d" tim_out)
(message "%s" "lett") ))
```
Note that this will still produce an error, because the first `message` has a
format string that requires two arguments but only one is given.
--
Joost Kremers
Life has its moments
- Understanding the "let" construct and the setting of variables, steve-humphreys, 2020/12/16
- Re: Understanding the "let" construct and the setting of variables, Jean Louis, 2020/12/16
- Re: Understanding the "let" construct and the setting of variables, steve-humphreys, 2020/12/17
- Re: Understanding the "let" construct and the setting of variables, Emanuel Berg, 2020/12/19
- Re: Understanding the "let" construct and the setting of variables, Jean Louis, 2020/12/19
- Re: Understanding the "let" construct and the setting of variables, Emanuel Berg, 2020/12/20
Re: Understanding the "let" construct and the setting of variables, Emanuel Berg, 2020/12/18