From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 14AF0BBAF for ; Tue, 26 Oct 2010 18:10:26 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj0EAK+axkzUGyoCkWdsb2JhbACDH441j3kVAQEBAQkLCgcRAx+ue5ITgSKDMnQEilODCBk X-IronPort-AV: E=Sophos;i="4.58,242,1286143200"; d="scan'208";a="85222334" Received: from smtp2-g21.free.fr ([212.27.42.2]) by mail1-smtp-roc.national.inria.fr with ESMTP; 26 Oct 2010 18:10:23 +0200 Received: from [127.0.0.1] (unknown [81.57.61.170]) by smtp2-g21.free.fr (Postfix) with ESMTP id 576F14B00E5; Tue, 26 Oct 2010 18:10:16 +0200 (CEST) Message-ID: <4CC6FD65.7080603@free.fr> Date: Tue, 26 Oct 2010 18:10:13 +0200 From: Emmanuel Dieul User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2.11) Gecko/20101013 Thunderbird/3.1.5 MIME-Version: 1.0 To: Mathias Kende Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] type inference problem with Printf.sprintf ? References: <4CC6F9E9.9090003@free.fr> <1288109042.11135.77.camel@bohrium.pps.jussieu.fr> In-Reply-To: <1288109042.11135.77.camel@bohrium.pps.jussieu.fr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Antivirus: avast! (VPS 101026-0, 26/10/2010), Outbound message X-Antivirus-Status: Clean X-Spam: no; 0.00; inference:01 printf:01 sprintf:01 ocaml:01 0200,:01 printf:01 sprintf:01 mathias:98 1900:98 mathias:98 unix:01 unix:01 caml-list:01 int:01 argument:02 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