chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Using Format


From: Kon Lovett
Subject: Re: [Chicken-users] Using Format
Date: Wed, 5 Dec 2007 17:04:33 -0800


On Dec 5, 2007, at 2:50 PM, Peter Wright wrote:

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:

Also look at the 'format-modular' egg. A very different implementation of CL 'format' that is thread-safe.


#;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


_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users

Best Wishes,
Kon






reply via email to

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