* number-to-string-pad
@ 2018-01-27 7:06 Emanuel Berg
2018-01-27 8:27 ` number-to-string-pad Yuri Khan
[not found] ` <mailman.8069.1517041690.27995.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 3+ messages in thread
From: Emanuel Berg @ 2018-01-27 7:06 UTC (permalink / raw)
To: help-gnu-emacs
Did anyone do
(defun number-to-string-pad (number len)
(let*((num-str (number-to-string number))
(len-num-str (length num-str))
(pad-len (- len len-num-str)) )
(if (< 0 pad-len)
(let ((pad-prefix (make-string pad-len ?0)))
(concat pad-prefix num-str))
num-str) ))
?
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: number-to-string-pad
2018-01-27 7:06 number-to-string-pad Emanuel Berg
@ 2018-01-27 8:27 ` Yuri Khan
[not found] ` <mailman.8069.1517041690.27995.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 3+ messages in thread
From: Yuri Khan @ 2018-01-27 8:27 UTC (permalink / raw)
To: Emanuel Berg; +Cc: help-gnu-emacs
On Sat, Jan 27, 2018 at 2:06 PM, Emanuel Berg <moasen@zoho.com> wrote:
> Did anyone do
>
> (defun number-to-string-pad (number len)
(format "%04d" number)
If you don’t know the length beforehand, you could do:
(format (format "%%0%dd" len) number)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: number-to-string-pad
[not found] ` <mailman.8069.1517041690.27995.help-gnu-emacs@gnu.org>
@ 2018-01-27 11:09 ` Emanuel Berg
0 siblings, 0 replies; 3+ messages in thread
From: Emanuel Berg @ 2018-01-27 11:09 UTC (permalink / raw)
To: help-gnu-emacs
Yuri Khan wrote:
>> Did anyone do (defun number-to-string-pad
>> (number len)
>
> (format "%04d" number)
>
> If you don’t know the length beforehand, you
> could do:
>
> (format (format "%%0%dd" len) number)
Great, thanks.
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-27 11:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-27 7:06 number-to-string-pad Emanuel Berg
2018-01-27 8:27 ` number-to-string-pad Yuri Khan
[not found] ` <mailman.8069.1517041690.27995.help-gnu-emacs@gnu.org>
2018-01-27 11:09 ` number-to-string-pad Emanuel Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).