From: Jeremy Yallop <yallop@gmail.com>
To: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com>
Cc: OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] is there a way for turning strings to "format"s?
Date: Wed, 6 Nov 2013 12:57:13 +0000 [thread overview]
Message-ID: <CAAxsn=E6GkTO_daN4dhxxvw-2_3zvY7w1PJiRYELLAH2qcGrJQ@mail.gmail.com> (raw)
In-Reply-To: <527A389B.9070408@gmail.com>
On 6 November 2013 12:39, Matej Kosik
<5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote:
> I would like to ask, how to do something like:
>
> let computed_format = Printf.sprintf "%%0%dd" 5 in
> Printf.printf computed_format 42
For this example, you can use '*' in the format string to pass the
width as an argument
let computed_format = Printf.sprintf "%0*d" 5 in
computed_format 42
or even just
Printf.sprintf "%0*d" 5 42
next prev parent reply other threads:[~2013-11-06 12:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-06 12:39 Matej Kosik
2013-11-06 12:44 ` Simon Cruanes
2013-11-06 12:50 ` Robert Jakob
2013-11-06 12:57 ` Jeremy Yallop [this message]
2013-11-06 13:08 ` Matej Kosik
2013-11-06 12:54 "Mark Adams"
2013-11-07 7:33 ` Gabriel Scherer
2013-11-07 7:50 ` David MENTRE
2013-11-07 20:45 ` Ollie Frolovs
2013-11-07 21:14 ` Yaron Minsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAAxsn=E6GkTO_daN4dhxxvw-2_3zvY7w1PJiRYELLAH2qcGrJQ@mail.gmail.com' \
--to=yallop@gmail.com \
--cc=5764c029b688c1c0d24a2e97cd764f@gmail.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox