Browse thread
type inference problem with Printf.sprintf ?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2010-10-26 (16:04) |
From: | Mathias Kende <mathias@k...> |
Subject: | Re: [Caml-list] type inference problem with Printf.sprintf ? |
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