chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Using Format


From: Peter Wright
Subject: Re: [Chicken-users] Using Format
Date: Thu, 6 Dec 2007 07:50:14 +0900
User-agent: Mutt/1.5.16 (2007-06-11)

On 05/12 17:00:20, 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 is as is.

I don't think you can do it with the default format/sprintf, but with
the format egg you can:

#;1> (use format)
; loading /usr/local/lib/chicken/3/format.so ...
#;2> (format #t "~2,'0D~%" 9)
09
#t
#;3> (format #t "~2,'0D~%" 10)
10
#t

> Bill

There's an example here (search for "zero"):

http://www.lisp.org/HyperSpec/Body/sec_22-3.html

Pete.
-- 
C makes it easy for you to shoot yourself in the foot. C++ makes that
harder, but when you do, it blows away your whole leg.
                -- Bjarne Stroustrup




reply via email to

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