From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id D3F2A7EE25 for ; Wed, 6 Nov 2013 13:54:41 +0100 (CET) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of mark@proof-technologies.com) identity=pra; client-ip=85.233.160.19; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mark@proof-technologies.com"; x-sender="mark@proof-technologies.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of mark@proof-technologies.com designates 85.233.160.19 as permitted sender) identity=mailfrom; client-ip=85.233.160.19; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mark@proof-technologies.com"; x-sender="mark@proof-technologies.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of postmaster@smtp.hosts.co.uk designates 85.233.160.19 as permitted sender) identity=helo; client-ip=85.233.160.19; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="mark@proof-technologies.com"; x-sender="postmaster@smtp.hosts.co.uk"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah8EAHk7elJV6aATlWdsb2JhbABagz+DW6lXlAQWDgEBAQEHDQkJEiqCJQEBBCQERxAWGgIJHQIjGwQFGBMSh10DCQoBCJ0NjwiITAMKiWuBKYs+gw+CVYFFA48ahweBa4EvhHoUhhWIXjw X-IPAS-Result: Ah8EAHk7elJV6aATlWdsb2JhbABagz+DW6lXlAQWDgEBAQEHDQkJEiqCJQEBBCQERxAWGgIJHQIjGwQFGBMSh10DCQoBCJ0NjwiITAMKiWuBKYs+gw+CVYFFA48ahweBa4EvhHoUhhWIXjw X-IronPort-AV: E=Sophos;i="4.93,647,1378850400"; d="scan'208";a="34015092" Received: from smtp.hosts.co.uk ([85.233.160.19]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Nov 2013 13:54:41 +0100 Received: from [192.168.0.128] (helo=plod.namesco.net) by smtp.hosts.co.uk with esmtps (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1Ve2d6-0006sX-JX for caml-list@inria.fr; Wed, 06 Nov 2013 12:54:40 +0000 Received: from webmail by plod.namesco.net with local (Exim 4.72) (envelope-from ) id 1Ve2d6-0004km-GI for caml-list@inria.fr; Wed, 06 Nov 2013 12:54:40 +0000 To: From: =?utf-8?q?=22Mark=20Adams=22?= Reply-To: =?utf-8?q?=22Mark=20Adams=22?= MIME-Version: 1.0 X-Mailer: Namesco Webmail v3.0 Message-ID: <1383742480351@names.co.uk> Date: Wed, 06 Nov 2013 12:54:40 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] is there a way for turning strings to "format"s? There's always the nasty 'Obj.magic' for conversion between arbitrary types: let computed_format =3D Printf.sprintf "%%0%dd" 5 in Printf.printf (Obj.magic computed_format) 42 Surely there must be a nicer way of doing this, but I don't know of one. Mark. on 6/11/13 12:40 PM, Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote: > Hi, > > I would like to ask, how to do something like: > > let computed_format =3D Printf.sprintf "%%0%dd" 5 in > Printf.printf computed_format 42 > > The above code is rejected, because "computed_format" is of type "string" > whereas > > ('a -> 'b, out_channel, unit) format =3D > ('a -> 'b, out_channel, unit, unit, unit, unit) format6 > > type was expected. > > My question is: is it possible to turn strings to values that would be > accepted by Printf.printf as its first parameter? > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > >