guile-user
[Top][All Lists]
Advanced

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

Re: format left-padding with zero's ?


From: Thien-Thi Nguyen
Subject: Re: format left-padding with zero's ?
Date: Sat, 12 Oct 2002 03:26:48 -0700

   From: Jan Nieuwenhuizen <address@hidden>
   Date: Sat, 12 Oct 2002 11:28:26 +0200

       you can think of this procedure as Guile's `fprintf'.

you can think of it that way but only to understand the general concept
of an initial format string controlling subsequent argument processing.
beyond that are the (dreaded) details, for which you should see:

  http://www.supelec.fr/docs/cltl/clm/node200.html#SECTION002633000000000000000

the format strings are, in fact, much more general, powerful and hence
potentially complex, than that used by the printf family.  to save you
some time, here is how to do "%04x":

  guile> (use-modules (ice-9 format))
  guile> (format #t "~A ||~4,'0X||\n" (version) 9)
  1.4.1.91 ||0009||
  #t

btw, you can replace "A" and "X" with "a" and "x", respectively.  grep
around for "bit-field-diagram" for some playwork-in-progress w/ (ice-9
format).

thi




reply via email to

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