From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA20565; Wed, 19 May 2004 09:55:59 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA20274 for ; Wed, 19 May 2004 09:55:58 +0200 (MET DST) Received: from mallaury.noc.nerim.net (smtp-103-wednesday.noc.nerim.net [62.4.17.103]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4J7tvEV030508 for ; Wed, 19 May 2004 09:55:57 +0200 Received: from localhost (karryall.dnsalias.org [62.4.18.180]) by mallaury.noc.nerim.net (Postfix) with ESMTP id 1A1F462DB1; Wed, 19 May 2004 09:55:37 +0200 (CEST) Date: Wed, 19 May 2004 09:22:18 +0200 (CEST) Message-Id: <20040519.092218.74745648.oandrieu@nerim.net> To: swampy@spacebird.net Cc: caml-list@inria.fr, hmaon@bumba.net Subject: Re: [Caml-list] format4 query From: Olivier Andrieu In-Reply-To: <004901c43d68$aa348bc0$10015c0a@word> References: <004901c43d68$aa348bc0$10015c0a@word> X-Mailer: Mew version 4.0.64 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 40AB130D.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 andrieu:01 andrieu:01 2004:99 demonstrate:01 sprintf:01 kprintf:01 fmt:01 printf:01 kprintf:01 fmt:01 val:01 endline:01 olivier:02 olivier:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 = # 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