Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Passing printf format strings to functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Micha <micha-1@f...>
Subject: Re: [Caml-list] Passing printf format strings to functions
Hi,

Am Tuesday 14 September 2004 23:55 schrieb Erik de Castro Lopo:
> Hi all,
>     let rec print_string_pairs (fmt:string) =
>         function
>             [] -> print_endline ""
>
>         |    a :: b ->
>
>                 Printf.printf fmt (fst a) (snd a) ;
>                 print_string_pairs fmt b
>         ;;


I think the fmt variable has not to be of type string but of some format type.
there exists a conversion function in Pervasives:

val format_of_string : ('a, 'b, 'c, 'd) format4 -> ('a, 'b, 'c, 'd) format4
  (*format_of_string s returns a format string read from the string literal 
s.*)


 Michael

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners