[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] Re: Using Format
From: |
Tobia Conforto |
Subject: |
[Chicken-users] Re: Using Format |
Date: |
Thu, 6 Dec 2007 17:41:51 +0100 |
User-agent: |
Mutt/1.5.17 (2007-11-01) |
William Ramsay wrote:
> Is there an easy way to format a number with a possible leading zero
> using format or sprintf?
>
> In other words I want 9 to show us as 09 and 10 to show as is.
Of course, there's also the poor man's string padding, using srfi-13:
(define (number-pad num len)
(let ((str (number->string num)))
(if (>= (string-length str) len)
str
(string-pad str len #\0))))
Tobia