* [Caml-list] Is it possible to define a Printf.sprintf-like that is lazy?
@ 2014-10-28 9:27 Francois Berenger
2014-10-28 9:43 ` Adrien Nader
2014-10-28 9:44 ` Paolo Donadeo
0 siblings, 2 replies; 4+ messages in thread
From: Francois Berenger @ 2014-10-28 9:27 UTC (permalink / raw)
To: OCaml List
Hello,
I mean, the parameters are not formated unless the function is forced.
--
Regards,
Francois.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Is it possible to define a Printf.sprintf-like that is lazy?
2014-10-28 9:27 [Caml-list] Is it possible to define a Printf.sprintf-like that is lazy? Francois Berenger
@ 2014-10-28 9:43 ` Adrien Nader
2014-10-28 9:46 ` Gabriel Scherer
2014-10-28 9:44 ` Paolo Donadeo
1 sibling, 1 reply; 4+ messages in thread
From: Adrien Nader @ 2014-10-28 9:43 UTC (permalink / raw)
To: Francois Berenger; +Cc: OCaml List
Hi
On Tue, Oct 28, 2014, Francois Berenger wrote:
> Hello,
>
> I mean, the parameters are not formated unless the function is forced.
Have you looked at Printf.kfprintf and ikprintf (which is >= 4.00
iirc) ?
--
Adrien Nader
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Is it possible to define a Printf.sprintf-like that is lazy?
2014-10-28 9:27 [Caml-list] Is it possible to define a Printf.sprintf-like that is lazy? Francois Berenger
2014-10-28 9:43 ` Adrien Nader
@ 2014-10-28 9:44 ` Paolo Donadeo
1 sibling, 0 replies; 4+ messages in thread
From: Paolo Donadeo @ 2014-10-28 9:44 UTC (permalink / raw)
To: Francois Berenger; +Cc: OCaml List
[-- Attachment #1: Type: text/plain, Size: 557 bytes --]
Maybe something like:
*let lazy_printf =*
* let k s = lazy (sprintf "%s" s) in*
* ksprintf k*
On Tue, Oct 28, 2014 at 10:27 AM, Francois Berenger <
francois.berenger@inria.fr> wrote:
> Hello,
>
> I mean, the parameters are not formated unless the function is forced.
>
> --
> Regards,
> Francois.
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
*Paolo*
[-- Attachment #2: Type: text/html, Size: 1499 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Is it possible to define a Printf.sprintf-like that is lazy?
2014-10-28 9:43 ` Adrien Nader
@ 2014-10-28 9:46 ` Gabriel Scherer
0 siblings, 0 replies; 4+ messages in thread
From: Gabriel Scherer @ 2014-10-28 9:46 UTC (permalink / raw)
To: Adrien Nader; +Cc: Francois Berenger, OCaml List
let delayed_sprintf fmt = Printf.sprintf (fmt ^^ "%s");;
# let result = Printf.sprintf "%d) %s\n" 3 "foo";;
val result : string = "3) foo\n"
# let thunk = delayed_sprintf "%d) %s\n" 3 "foo";;
val thunk : string -> string = <fun>
# thunk "";;
- : string = "3) foo\n"
On Tue, Oct 28, 2014 at 10:43 AM, Adrien Nader <adrien@notk.org> wrote:
> Hi
>
> On Tue, Oct 28, 2014, Francois Berenger wrote:
>> Hello,
>>
>> I mean, the parameters are not formated unless the function is forced.
>
>
> Have you looked at Printf.kfprintf and ikprintf (which is >= 4.00
> iirc) ?
>
> --
> Adrien Nader
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-28 9:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-28 9:27 [Caml-list] Is it possible to define a Printf.sprintf-like that is lazy? Francois Berenger
2014-10-28 9:43 ` Adrien Nader
2014-10-28 9:46 ` Gabriel Scherer
2014-10-28 9:44 ` Paolo Donadeo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox