<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/10/7f88e86b9d298b383d73b6b58f84f6fb"
  from="Pierre Weis &lt;weis@p...&gt;"
  author="Pierre Weis"
  date="2003-10-08T14:48:11"
  subject="Re: [Caml-list] what is the functional way to solve this problem?"
  prev="2003/10/e79513aa34d4347fb9f61c4d83c4e732"
  next="2003/10/8e30e035c3408ed133428b3777754c4d"
  prev-in-thread="2003/10/01f8985812016e242ddd8d73bc92ef59"
  next-in-thread="2003/10/899d22452db6890e8647fbc2d53d9ee4"
  prev-thread="2003/10/261f050dccf87201bc913df1d656bf10"
  next-thread="2003/10/9a4a4be0cfe7c019ae4f42aaf4c47b30"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] what is the functional way to solve this problem?">
<msg 
  url="2003/10/af98552ca0ffbadca25a0ba23600da76"
  from="Ram Bhamidipaty &lt;ramb@s...&gt;"
  author="Ram Bhamidipaty"
  date="2003-10-02T12:41:52"
  subject="[Caml-list] what is the functional way to solve this problem?">
<msg 
  url="2003/10/01f8985812016e242ddd8d73bc92ef59"
  from="Michal Moskal &lt;malekith@p...&gt;"
  author="Michal Moskal"
  date="2003-10-02T14:55:22"
  subject="Re: [Caml-list] what is the functional way to solve this problem?">
<msg 
  url="2003/10/7f88e86b9d298b383d73b6b58f84f6fb"
  from="Pierre Weis &lt;weis@p...&gt;"
  author="Pierre Weis"
  date="2003-10-08T14:48:11"
  subject="Re: [Caml-list] what is the functional way to solve this problem?">
<msg 
  url="2003/10/899d22452db6890e8647fbc2d53d9ee4"
  from="Michal Moskal &lt;malekith@p...&gt;"
  author="Michal Moskal"
  date="2003-10-08T16:10:14"
  subject="Re: [Caml-list] what is the functional way to solve this problem?">
<msg 
  url="2003/10/f0d7a9095f1a80f5d23897d58bf50d50"
  from="Pierre Weis &lt;weis@p...&gt;"
  author="Pierre Weis"
  date="2003-10-08T20:34:41"
  subject="Re: [Caml-list] what is the functional way to solve this problem?">
<msg 
  url="2003/10/0ee5858b073f26c4cbcaef3bc64f2a02"
  from="Michal Moskal &lt;malekith@p...&gt;"
  author="Michal Moskal"
  date="2003-10-08T21:25:11"
  subject="scanf (Re: [Caml-list] what is the functional way to solve this problem?)">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Hi Michal,

[...]
&gt; Key points of my implementation:
[...]
&gt; 3. It doesn't use Scanf. For such linear task as this Scanf takes 10 or
&gt;    more times to parse input then actual computations.
[...]
&gt; -- 
&gt; : Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv
&gt; : When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}&gt;+++ h

I'm sorry to report that I was so puzzled by your number 3) key point,
that I tested your code and a ``purely scanf'' version to see this
``10 or more times to parse'' behaviour; I didn't notice any runtime
difference between the two (native code compiled) versions. Am I
missing something ?

Could you please try to use the following version of your read
function, and report the runtime difference between your hand written
code ?

(BTW, I compiled the 2 programs using ocamlopt -unsafe -inline 9)

let read () =
  try
    Scanf.bscanf Scanf.Scanning.stdib " %c" (function
    | 'D' -&gt;
        Scanf.bscanf Scanf.Scanning.stdib " %d %d %s"
        (fun x y s -&gt; D (x, y, s))
    | 'F' -&gt;
        Scanf.bscanf Scanf.Scanning.stdib " %d %s"
        (fun x s -&gt; F (x, s))
    | _ -&gt; invalid_arg "read")
  with End_of_file -&gt; Eof

You should also replace
(*
  let l = read_line () in
  let (dh, fh) = Scanf.sscanf l "R 0 %[^\n]" start in
*)
by

  let (dh, fh) = Scanf.bscanf Scanf.Scanning.stdib "R 0 %s@\n" start in

Looking forward for reading from you,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


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

</contents>

</message>

