From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 43FFEBC69 for ; Tue, 2 Oct 2007 23:16:44 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAALhPAkfC2fJWn2dsb2JhbACONgEBAQEHBAYHCBg X-IronPort-AV: E=Sophos;i="4.21,221,1188770400"; d="scan'208";a="2035044" Received: from anchor-post-36.mail.demon.net ([194.217.242.86]) by mail1-smtp-roc.national.inria.fr with ESMTP; 02 Oct 2007 23:16:44 +0200 Received: from orion.metastack.com ([80.177.38.218]) by anchor-post-36.mail.demon.net with esmtp (Exim 4.67) id 1Icp6h-0003bc-Kt; Tue, 02 Oct 2007 21:16:43 +0000 Received: from countertenor (cpc3-cmbg6-0-0-cust100.cmbg.cable.ntl.com [81.101.140.101]) (authenticated bits=0) by orion.metastack.com (8.13.4/8.13.3) with ESMTP id l92LEaGU000805 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); Tue, 2 Oct 2007 22:14:36 +0100 From: "David Allsopp" To: "'kirillkh'" Cc: References: <779bf2730710011427g5983da4cw6ad8b715a9e38771@mail.gmail.com><47016CEE.8010704@crans.org> <200710021239.l92CdwZ15641@virtutech.se><47024002.2080206@janestcapital.com><95513600710021323u762efd5k5ee6bdd03d7cc37@mail.gmail.com> Subject: RE: [Caml-list] best and fastest way to read lines from a file? Date: Tue, 2 Oct 2007 22:15:53 +0100 Organization: MetaStack Solutions Ltd. Message-ID: <004601c80539$6a8a4360$017ca8c0@countertenor> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 In-Reply-To: Thread-Index: AcgFNX93+vTQ9K+mQNae52et5RA1fgAA5WQg X-Spam: no; 0.00; inherently:01 ocaml:01 recursive:01 caml-list:01 tail:01 imperative:01 implemented:02 functional:02 construct:02 slightly:03 ugly:04 brian:05 i'd:06 fold:06 long:06 > A little weird to see such inherently functional construct as fold implemented imperatively. But it's fine with me, as long as it does the job. I > wonder, though, how would the performance of a line counter based on your code compare with the one suggested by Brian. It's faster, though only slightly - I was going to post an imperative solution earlier, too. Even in Ocaml, a recursive call (tail or otherwise) has some costs not present in a simple loop. However, I don't agree that it's more natural - "ugly" is more the word I'd use! David