Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] format4 query
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Olivier Andrieu <andrieu@i...>
Subject: Re: [Caml-list] format4 query
 David J. Trombley [Wed, 19 May 2004]:
 > 
 > Suppose I have
 > 
 > type listener = string -> unit
 > 
 > which is intended to receive a string type as a value.
 > 
 > Could someone demonstrate a function that takes a listener
 > and a format as arguments, and uses sprintf to obtain a
 > string, and then calls the listener with the string
 > argument? 

That is precisely what kprintf does.

# type listener = string -> unit;;
type listener = string -> unit
# let f (l : listener) fmt = Printf.kprintf l fmt ;;
val f : listener -> ('a, unit, string, unit) format4 -> 'a = <fun>
# f print_endline "%s %d" "abc" 23 ;;
abc 23
- : unit = ()

-- 
   Olivier

-------------------
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