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: | -- (:) |
| From: | Emmanuel Dieul <emmanuel.dieul@f...> |
| Subject: | Re: [Caml-list] type inference problem with Printf.sprintf ? |
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