From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=AWL,UNPARSEABLE_RELAY autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id EF95ABB84 for ; Thu, 28 Aug 2008 15:38:33 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmkDAGRHtkiTIFAHiGdsb2JhbACSOwEBAQ8gRKcwgWk X-IronPort-AV: E=Sophos;i="4.32,286,1217800800"; d="scan'208";a="16359481" Received: from relay.felk.cvut.cz ([147.32.80.7]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 28 Aug 2008 15:38:26 +0200 X-FELK-MailScanner-Watermark: 1220535500.34539@B6N9sJ7nG+HTeNPuf5GpMg Received: from k333.felk.cvut.cz (k333.felk.cvut.cz [147.32.87.5]) by relay.felk.cvut.cz (8.14.2/8.14.2) with ESMTP id m7SDcHqL090106 for ; Thu, 28 Aug 2008 15:38:17 +0200 (CEST) (envelope-from kybic@fel.cvut.cz) Received: from K333/SpoolDir by k333.felk.cvut.cz (Mercury 1.48); 28 Aug 08 15:38:17 +0100 Received: from SpoolDir by K333 (Mercury 1.48); 28 Aug 08 15:37:50 +0100 Received: from localhost (147.32.84.19) by k333.felk.cvut.cz (Mercury 1.48) with ESMTP; 28 Aug 08 15:37:46 +0100 To: caml-list@yquem.inria.fr Subject: Run-time evaluation of a Printf format string Reply-To: Jan Kybic From: Jan Kybic Date: Thu, 28 Aug 2008 15:37:46 +0200 Message-ID: <87hc951cr9.fsf@fel.cvut.cz> User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0 (relay.felk.cvut.cz [147.32.80.7]); Thu, 28 Aug 2008 15:38:17 +0200 (CEST) X-FELK-MailScanner-Information: X-MailScanner-ID: m7SDcHqL090106 X-FELK-MailScanner: Found to be clean X-FELK-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-2.599, required 5, autolearn=not spam, BAYES_00 -2.60) X-FELK-MailScanner-From: kybic@fel.cvut.cz X-FELK-MailScanner-To: caml-list@yquem.inria.fr X-Spam: no; 0.00; run-time:01 printf:01 printf:01 sprintf:01 %03:01 ocaml:01 pervasives:01 img:98 strings:01 motivation:02 string:02 string:02 external:03 seems:03 library:03 Hello, I would need an equivalent of Printf.sprintf where the format string is not constant, it is read from the command line. The motivation is to let the user specify a template for file names, such as "img%03d.png". Can this be achieved in Ocaml? It seems not, as Pervasives.string_of_format only accepts constant strings. Or is there some external library useful for this task? For the moment I have started to implement it myself for the limited set of format specifications I will need but if there is some more elegant solution I would be interested to hear about it. Thanks, Jan -- ------------------------------------------------------------------------- Jan Kybic tel. +420 2 2435 5721 http://cmp.felk.cvut.cz/~kybic ICQ 200569450 D