From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA13139; Tue, 18 Mar 2003 10:25:09 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA03996 for ; Tue, 18 Mar 2003 10:25:08 +0100 (MET) Received: from hirsch.in-berlin.de (hirsch.in-berlin.de [192.109.42.6]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h2I9P7f24491 for ; Tue, 18 Mar 2003 10:25:07 +0100 (MET) Received: from hirsch.in-berlin.de (localhost [127.0.0.1]) by hirsch.in-berlin.de (8.12.8/8.12.8/Debian-2) with ESMTP id h2I9P7n0024369 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NOT) for ; Tue, 18 Mar 2003 10:25:07 +0100 Received: from first.UUCP (uucp@localhost) by hirsch.in-berlin.de (8.12.8/8.12.8/Debian-2) with UUCP id h2I9P7Zq024367 for inria.fr!caml-list; Tue, 18 Mar 2003 10:25:07 +0100 X-Envelope-From: oliver@first.in-berlin.de X-Envelope-To: inria.fr!caml-list Received: by first.in-berlin.de via sendmail from stdin id (Debian Smail3.2.0.114) Tue, 18 Mar 2003 09:52:32 +0100 (CET) From: oliver@first.in-berlin.de (Oliver Bandel) Date: Tue, 18 Mar 2003 09:52:32 +0100 To: caml-list@inria.fr Subject: Re: [Caml-list] Loop times Message-ID: <20030318085232.GB372@first.in-berlin.de> Mail-Followup-To: oliver, caml-list@inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline User-Agent: Mutt/1.3.28i X-Spam: no; 0.00; oliver:01 in-berlin:01 bandel:01 caml-list:01 helper:01 rec:01 match:02 exception:02 ciao:02 wrote:03 recursive:03 btw:03 tail:03 variable:03 imperative:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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