all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using variable in let for different data
@ 2022-12-07  0:46 Heime
  2022-12-07  1:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 2+ messages in thread
From: Heime @ 2022-12-07  0:46 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

Is it acceptable to store the nanosecond from `split-string`, then to convert it
to a number using the same variable name?

  (let* ( (tm  (format-time-string "%FT%T.%N%z" nil tzone))
          (ns  (nth 6 (split-string tm "[^[:digit:]]")))
          (ns  (string-to-number ns))           ; nanoseconds
          (ss  (nth 0 (parse-time-string tm)))  ; seconds
          (mm  (nth 1 (parse-time-string tm)))  ; minutes
          (hh  (nth 2 (parse-time-string tm)))  ; hours
          (lc  (make-vector 6 0)) )






^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Using variable in let for different data
  2022-12-07  0:46 Using variable in let for different data Heime
@ 2022-12-07  1:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-12-07  1:07 UTC (permalink / raw)
  To: help-gnu-emacs

> Is it acceptable to store the nanosecond from `split-string`, then to
> convert it to a number using the same variable name?
>
>   (let* ( (tm  (format-time-string "%FT%T.%N%z" nil tzone))
>           (ns  (nth 6 (split-string tm "[^[:digit:]]")))
>           (ns  (string-to-number ns))           ; nanoseconds

Yes.  The second `ns` just shadows the first in the rest of the code.


        Stefan




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-07  1:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07  0:46 Using variable in let for different data Heime
2022-12-07  1:07 ` Stefan Monnier via Users list for the GNU Emacs text editor

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.