[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | oliver@f... |
| Subject: | Re: [Caml-list] Loop times |
On Mon, Mar 17, 2003 at 02:01:21PM -0800, Daniel M. Albro wrote:
>
> Sorry, I just meant that the version that puts the
> exception into a variable outside of the loop is a win over
> the one that creates the exception inside the loop.
What does this mean for such a version of reading a file
linewise into a list of strings?
let input_lines chan =
let rec input_lines_helper res =
let sl =
try
Some (input_line chan)
with
End_of_file -> None in
match sl with
None -> List.rev res
| Some l -> input_lines_helper (l :: res) in
input_lines_helper []
There is a try-with inside the reacursive function.
But is there a way to avoid it?
Well... I may re-read all the mails and put them together to
one mail or may produce a little paper on that topic?
I have to sort the many new things in FPL-programming
for better understanding....
Or maybe you are interested in collecting all results together
into one conclusion-mail?
(Would be nice. :))
> The
> fastest loop routine overall was the tail recursive loop,
> i.e. the functional/recursive.
BTW: This is new to me. Even OCaml-people told me, that
the imperative version of loops will be faster than
recursive/functional.
That's good news for FP-programming, but that's also
bad news for people, who want to optimize their
functional programs in speed.
> However, this latest
> imperative version has timing that's very close -- the
> imperative version that pre-builds the exception takes
> just over 28 seconds, and the tail-recursive version
> takes just under 27 seconds.
OK.
Can you give me a short advice on the recursive
Input-function, mantioned above?
Thanks.
Ciao,
Oliver
-------------------
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