caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Emmanuel Dieul <emmanuel.dieul@free.fr>
To: Mathias Kende <mathias@kende.fr>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] type inference problem with Printf.sprintf ?
Date: Tue, 26 Oct 2010 18:10:13 +0200	[thread overview]
Message-ID: <4CC6FD65.7080603@free.fr> (raw)
In-Reply-To: <1288109042.11135.77.camel@bohrium.pps.jussieu.fr>

Of course. I have to admit I've been a long time without developing in OCaml...
Thanks !

Le 26/10/2010 18:04, Mathias Kende a écrit :
> Le mardi 26 octobre 2010 à 17:55 +0200, Emmanuel Dieul a écrit :
>> let format_date =
>>     let format_valeur = function valeur ->
>>       (if valeur<  10 then "0" else "") ^ (string_of_int valeur)
>>     in
>>     function date ->
>>       Printf.sprintf "%s/%s/%l %s:%s:%s"
>>         format_valeur(date.Unix.tm_mday)
>>         (format_valeur(date.Unix.tm_mon + 1) : string)
>>         (date.Unix.tm_year + 1900)
>>         (format_valeur(date.Unix.tm_hour) : string)
>>         (format_valeur(date.Unix.tm_min) : string)
>>         (format_valeur(date.Unix.tm_sec) : string)
>> ;;
>>
> Here, the argument to the Printf.sprintf function are :
> "%s/%s/%l %s:%s:%s", format_valeur, date.Unix.tm_mday, ...
>
> Just add parenthesis around (format_valeur date.Unix.tm_mday) (but
> without any type annotation) to pass the _result_ of this application to
> the sprintf function. You don't need parenthesis around the argument of
> the function though.
>
> Mathias
>

-- 
*Emmanuel Dieul*
	122, rue Salvador Allende
boîte 25
92000 Nanterre

http://emmanuel.dieul.free.fr


  reply	other threads:[~2010-10-26 16:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-26 15:55 Emmanuel Dieul
2010-10-26 16:04 ` [Caml-list] " Mathias Kende
2010-10-26 16:10   ` Emmanuel Dieul [this message]
2010-10-26 21:44     ` Arlen Cuss
2010-10-27 11:30       ` Richard Jones
2010-11-03 13:47         ` Gregory Bellier
2010-11-03 14:43           ` Sylvain Le Gall
2010-11-03 15:33             ` [Caml-list] " Benedikt Grundmann
2010-11-03 16:23               ` Dario Teixeira
2010-10-26 21:41 ` [Caml-list] " David Allsopp

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=4CC6FD65.7080603@free.fr \
    --to=emmanuel.dieul@free.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=mathias@kende.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;
as well as URLs for NNTP newsgroup(s).