caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Olivier Andrieu <andrieu@ijm.jussieu.fr>
To: swampy@spacebird.net
Cc: caml-list@inria.fr, hmaon@bumba.net
Subject: Re: [Caml-list] format4 query
Date: Wed, 19 May 2004 09:22:18 +0200 (CEST)	[thread overview]
Message-ID: <20040519.092218.74745648.oandrieu@nerim.net> (raw)
In-Reply-To: <004901c43d68$aa348bc0$10015c0a@word>

 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


  reply	other threads:[~2004-05-19  7:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-19  6:15 David J. Trombley
2004-05-19  7:22 ` Olivier Andrieu [this message]
2004-05-19 16:13   ` David J. Trombley
2004-05-19 17:20     ` Damien Doligez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040519.092218.74745648.oandrieu@nerim.net \
    --to=andrieu@ijm.jussieu.fr \
    --cc=caml-list@inria.fr \
    --cc=hmaon@bumba.net \
    --cc=swampy@spacebird.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).