From: oliver@first.in-berlin.de (Oliver Bandel)
To: caml-list@inria.fr
Subject: Re: [Caml-list] Loop times
Date: Tue, 18 Mar 2003 09:52:32 +0100 [thread overview]
Message-ID: <20030318085232.GB372@first.in-berlin.de> (raw)
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
next reply other threads:[~2003-03-18 9:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-18 8:52 Oliver Bandel [this message]
2003-03-18 15:21 ` Florian Hars
2003-03-18 15:40 ` Noel Welsh
2003-03-19 6:48 ` Daniel M. Albro
-- strict thread matches above, loose matches on Subject: below --
2003-03-13 21:53 Daniel M. Albro
2003-03-17 11:39 ` Fabrice Le Fessant
2003-03-17 18:59 ` Daniel M. Albro
[not found] ` <20030317214841.GA467@first.in-berlin.de>
2003-03-17 22:01 ` Daniel M. Albro
2003-03-18 9:57 ` Oliver Bandel
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=20030318085232.GB372@first.in-berlin.de \
--to=oliver@first.in-berlin.de \
--cc=caml-list@inria.fr \
/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