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 RAA18493; Wed, 28 Apr 2004 17:28:37 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA18169 for ; Wed, 28 Apr 2004 17:28:36 +0200 (MET DST) Received: from web60608.mail.yahoo.com (web60608.mail.yahoo.com [216.109.119.82]) by nez-perce.inria.fr (8.12.10/8.12.10) with SMTP id i3SFSYjq029054 for ; Wed, 28 Apr 2004 17:28:35 +0200 Message-ID: <20040428152813.47355.qmail@web60608.mail.yahoo.com> Received: from [200.137.225.3] by web60608.mail.yahoo.com via HTTP; Wed, 28 Apr 2004 12:28:13 ART Date: Wed, 28 Apr 2004 12:28:13 -0300 (ART) From: =?iso-8859-1?q?Andr=E9=20Luiz=20Moura?= Subject: [Caml-list] Reading a large text file To: caml-list@inria.fr MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1154743823-1083166093=:47196" Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 implemented:01 seus:99 amigos:99 caml-list:01 implemented:01 seus:99 amigos:99 million:98 million:98 ocaml:01 ocaml:01 marker:02 marker:02 wrote:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --0-1154743823-1083166093=:47196 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi List, I wrote an OCaml function to read a text file with a million of lines with five separate columns for spaces. I based myself on previous messages of Caml-list, but however the work is taking time frightful (many minutes). This function written in C, for example, does not take more than 4 seconds. I am executing the program in a PC Pentium III of 128 MB of RAM under Windows platform. How would be implemented the function to decide this problem? File format: [attributes] [boundary marker] Thanks, André --------------------------------- Yahoo! Messenger - Fale com seus amigos online. Instale agora! --0-1154743823-1083166093=:47196 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit
Hi List,
 
I wrote an OCaml function to read a text file with a million of lines with  five separate columns for spaces. I based myself on previous messages of Caml-list, but however the work is taking time frightful (many minutes).
This function written in C, for example, does not take more than 4 seconds.
 
I am executing the program in a PC Pentium III of 128 MB of RAM under Windows platform. How would be implemented the function to decide this problem?

File format:
<vertex #> <x> <y> [attributes] [boundary marker]
Thanks,
André




Yahoo! Messenger - Fale com seus amigos online. Instale agora! --0-1154743823-1083166093=:47196-- ------------------- 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 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 SAA05627; Wed, 28 Apr 2004 18:28:17 +0200 (MET DST) 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 SAA05616 for ; Wed, 28 Apr 2004 18:28:16 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i3SGSFYM024448 for ; Wed, 28 Apr 2004 18:28:15 +0200 Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1BIrux-0006Nq-00 for ; Wed, 28 Apr 2004 17:28:15 +0100 Date: Wed, 28 Apr 2004 17:28:15 +0100 Cc: caml-list@inria.fr Subject: Re: [Caml-list] Reading a large text file Message-ID: <20040428162815.GA24500@redhat.com> References: <20040428152813.47355.qmail@web60608.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040428152813.47355.qmail@web60608.mail.yahoo.com> User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 caml-list:01 implemented:01 ltd:98 million:98 ocaml:01 marker:02 0300,:02 wrote:03 wrote:03 configurable:03 perl:03 vertex:04 executing:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Apr 28, 2004 at 12:28:13PM -0300, Andr? Luiz Moura wrote: > Hi List, > > I wrote an OCaml function to read a text file with a million of lines with five separate columns for spaces. I based myself on previous messages of Caml-list, but however the work is taking time frightful (many minutes). > This function written in C, for example, does not take more than 4 seconds. > > I am executing the program in a PC Pentium III of 128 MB of RAM under Windows platform. How would be implemented the function to decide this problem? > > File format: > [attributes] [boundary marker] Post some example code? Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment NET::FTPSERVER is a full-featured, secure, configurable, database-backed FTP server written in Perl: http://www.annexia.org/freeware/netftpserver/ ------------------- 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 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 PAA25475; Sat, 1 May 2004 15:58:46 +0200 (MET DST) 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 PAA25303 for ; Sat, 1 May 2004 15:58:45 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i41DwhSH027383 for ; Sat, 1 May 2004 15:58:44 +0200 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.11.6/8.10.1) with ESMTP id i41DwdR19584; Sat, 1 May 2004 08:58:40 -0500 (CDT) Date: Sat, 1 May 2004 09:03:56 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: =?iso-8859-1?q?Andr=E9=20Luiz=20Moura?= cc: caml-list@inria.fr Subject: Re: [Caml-list] Reading a large text file In-Reply-To: <20040428152813.47355.qmail@web60608.mail.yahoo.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT X-Miltered: at concorde with ID 4093AD13.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 digging:01 appending:01 appending:01 caml-list:01 implemented:01 seus:99 amigos:99 million:98 ocaml:01 ocaml:01 rec:01 rec:01 catching:02 marker:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I'm still digging through a serious backlog of email, so your question may have already been answered. If so, ignore this. But what I'm guessing is happening is that you are appending (adding to the end of) your list, and that this is what is killing you. To add an element to the *end* of a list, Ocaml has to completely reallocate the entire list- turning what you might think is an O(1) operation into an O(n) operation. The solution to this is to build the list backwards- instead of adding things to the end of the list, add them to the begining. Then, when you're done, just reverse the list using List.rev. Lets look at the example of just reading the lines from a file and making a list of them. This code is bad: let readfile chan = let rec loop lst = try loop (lst @ [ (input_line chan) ]) with | End_of_file -> lst in loop [] ;; It works, but to read n lines requires O(n^2) work, because the @ has to reallocate the entire list every iteration. Worse yet it isn't tail recursive (a recursive call inside a try/catch isn't a tail call). A better implementation of this would be: let readfile chan = let rec loop rlst = let line, eof = try (input_line chan), false with | End_of_file -> "", true in if not eof then loop (line :: rlst) else List.rev rlst in loop [] ;; Now, the first thing to notice is that we're using the :: operator (which is O(1)), not the @ operator (which is O(n))- we're prepending things onto the list, not appending them. We're building up the list backwards, and then, when we hit the end of the file, reversing the entire list. This is a standard pattern in Ocaml. The second thing to notice is that the recursive call has been hoisted up out of the try/catch block. We've introduced a new boolean flag to note when we've hit the end of the file- catching the exception simply sets the flag to true. So now our function is tail recursive, and operates in constant stack space. Brian On Wed, 28 Apr 2004, André Luiz Moura wrote: > Hi List, > > I wrote an OCaml function to read a text file with a million of lines with five separate columns for spaces. I based myself on previous messages of Caml-list, but however the work is taking time frightful (many minutes). > This function written in C, for example, does not take more than 4 seconds. > > I am executing the program in a PC Pentium III of 128 MB of RAM under Windows platform. How would be implemented the function to decide this problem? > > File format: > [attributes] [boundary marker] > > Thanks, > > André > > > > > > > --------------------------------- > Yahoo! Messenger - Fale com seus amigos online. Instale agora! -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- 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 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 RAA31311; Sat, 1 May 2004 17:43:56 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id RAA31307 for ; Sat, 1 May 2004 17:43:55 +0200 (MET DST) Received: from scaup.mail.pas.earthlink.net (scaup.mail.pas.earthlink.net [207.217.120.49]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i41FhsEV020787 for ; Sat, 1 May 2004 17:43:54 +0200 Received: from user-0cdfepc.cable.mindspring.com ([24.215.187.44] helo=bluerondo) by scaup.mail.pas.earthlink.net with smtp (Exim 3.33 #1) id 1BJwef-0004B6-00 for caml-list@inria.fr; Sat, 01 May 2004 08:43:53 -0700 Received: (qmail 5340 invoked by uid 1002); 1 May 2004 15:43:51 -0000 Date: Sat, 1 May 2004 11:43:51 -0400 From: Rahul Siddharthan To: Brian Hurt Cc: Andr? Luiz Moura , caml-list@inria.fr Subject: Re: [Caml-list] Reading a large text file Message-ID: <20040501154351.GA5218@online.fr> References: <20040428152813.47355.qmail@web60608.mail.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: DragonFly 1.0-CURRENT i386 User-Agent: Mutt/1.5.6i X-Miltered: at nez-perce with ID 4093C5BA.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 appending:01 arrays:01 ocaml:01 begining:02 seems:05 brian:06 traverse:07 i'm:07 i'm:07 lists:91 guessing:09 puzzled:10 solution:10 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Brian Hurt said on May 1, 2004 at 09:03:56: > But what I'm guessing is happening is that you are appending (adding to > the end of) your list, and that this is what is killing you. To add an > element to the *end* of a list, Ocaml has to completely reallocate the > entire list- turning what you might think is an O(1) operation into an > O(n) operation. I'm pretty puzzled by that: why would it have to do that? Arrays, yes, but lists, can't it just traverse the existing list to its end and then add a new element? It's still O(n) but no reallocation. > The solution to this is to build the list backwards- instead of adding > things to the end of the list, add them to the begining. Then, when > you're done, just reverse the list using List.rev. Yes that seems best. Rahul ------------------- 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 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 SAA32139; Sat, 1 May 2004 18:00:27 +0200 (MET DST) 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 SAA32313 for ; Sat, 1 May 2004 18:00:26 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from web41905.mail.yahoo.com (web41905.mail.yahoo.com [66.218.93.156]) by concorde.inria.fr (8.12.10/8.12.10) with SMTP id i41G0OSH025540 for ; Sat, 1 May 2004 18:00:25 +0200 Message-ID: <20040501160024.1862.qmail@web41905.mail.yahoo.com> Received: from [193.55.28.173] by web41905.mail.yahoo.com via HTTP; Sat, 01 May 2004 18:00:24 CEST Date: Sat, 1 May 2004 18:00:24 +0200 (CEST) From: =?iso-8859-1?q?sejourne=20kevin?= Subject: [Caml-list] [OcamlDoc] langage support. To: caml-list@inria.fr In-Reply-To: <20040501154351.GA5218@online.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 4093C998.003 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; ocamldoc:01 ocamldoc:01 evry:01 gratuit:96 grace:96 langage:04 langage:04 let:04 e-mail:94 something:09 vos:90 telechargez:89 think:11 votre:88 votre:88 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi evrybody! Is there a way in Ocamldoc to make multilingual documentation ? I think of something like that : (** [En] Reverse a list. [Fr] Retourne une liste. [Es] ... *) Let rev = List.rev ;; And generate documentation file in evry langage use in the code? Kevin Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout ! Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/ Dialoguez en direct avec vos amis grâce à Yahoo! Messenger !Téléchargez Yahoo! Messenger sur http://fr.messenger.yahoo.com ------------------- 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 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 UAA05686; Sat, 1 May 2004 20:05:11 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA05695 for ; Sat, 1 May 2004 20:05:09 +0200 (MET DST) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i41I58EV005226 for ; Sat, 1 May 2004 20:05:08 +0200 Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1BJyrM-0004QT-00 for ; Sat, 01 May 2004 19:05:08 +0100 Date: Sat, 1 May 2004 19:05:08 +0100 Cc: caml-list@inria.fr Subject: Re: [Caml-list] Reading a large text file Message-ID: <20040501180508.GA16958@redhat.com> References: <20040428152813.47355.qmail@web60608.mail.yahoo.com> <20040501154351.GA5218@online.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040501154351.GA5218@online.fr> User-Agent: Mutt/1.5.5.1+cvs20040105i From: Richard Jones X-Miltered: at nez-perce with ID 4093E6D4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 2004:99 0400,:01 2004:99 appending:01 immutable:01 disadvantage:01 bug:01 mylist:01 mylist:01 val:01 val:01 autoconf:01 automake:01 compiles:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, May 01, 2004 at 11:43:51AM -0400, Rahul Siddharthan wrote: > Brian Hurt said on May 1, 2004 at 09:03:56: > > But what I'm guessing is happening is that you are appending (adding to > > the end of) your list, and that this is what is killing you. To add an > > element to the *end* of a list, Ocaml has to completely reallocate the > > entire list- turning what you might think is an O(1) operation into an > > O(n) operation. > > I'm pretty puzzled by that: why would it have to do that? Arrays, > yes, but lists, can't it just traverse the existing list to its end > and then add a new element? It's still O(n) but no reallocation. The short answer is no, because in OCaml (unlike in LISP) lists are immutable. In LISP terminology, there's no way to 'set cdr' on an OCaml 'cons structure'. The disadvantage to this is that you can't do certain destructive operations on lists, like you can so easily in LISP. The advantage is that you can't do certain destructive operations on lists! In other words, your code is more likely to be bug free. However, OCaml is a practical language and so allows you to create a mutable cons structure if you so desire. eg: # type 'a mylist = { head : 'a; mutable tail : 'a mylist option };; type 'a mylist = { head : 'a; mutable tail : 'a mylist option; } # let xs = { head = 10; tail = None };; val xs : int mylist = {head = 10; tail = None} # let xs = { head = 5; tail = Some xs};; val xs : int mylist = {head = 5; tail = Some {head = 10; tail = None}} # let ys = { head = 20; tail = None };; (* new tail *) val ys : int mylist = {head = 20; tail = None} # xs.tail <- Some ys;; (* replace tail of xs *) - : unit = () # xs;; - : int mylist = {head = 5; tail = Some {head = 20; tail = None}} Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment MAKE+ is a sane replacement for GNU autoconf/automake. One script compiles, RPMs, pkgs etc. Linux, BSD, Solaris. http://www.annexia.org/freeware/makeplus/ ------------------- 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 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 UAA04021; Sat, 1 May 2004 20:25:45 +0200 (MET DST) 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 UAA05948 for ; Sat, 1 May 2004 20:25:44 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from lavoro.terzarima.net (spc1-york1-5-0-cust44.leed.broadband.ntl.com [80.0.45.44]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i41IPhSH019731 for ; Sat, 1 May 2004 20:25:43 +0200 Message-ID: To: caml-list@inria.fr Subject: Re: [Caml-list] Reading a large text file From: Charles Forsyth Date: Sat, 1 May 2004 19:25:12 +0100 In-Reply-To: <20040501180508.GA16958@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4093EBA7.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 forsyth:01 forsyth:01 immutable:01 disadvantage:01 bug:01 appending:01 implemented:01 hash:01 ocaml:01 ocaml:01 mutable:01 lisp:01 lisp:01 penalty:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >>The short answer is no, because in OCaml (unlike in LISP) lists are >>immutable. In LISP terminology, there's no way to 'set cdr' on an >>OCaml 'cons structure'. The disadvantage to this is that you can't do >>certain destructive operations on lists, like you can so easily in >>LISP. The advantage is that you can't do certain destructive >>operations on lists! In other words, your code is more likely to be >>bug free. the concurrent programming language Limbo does much the same, and has a similar penalty for appending to a list. nevertheless, it has advantages as you say, and i thought i'd add that the property turns out to be quite helpful in concurrent programs, because you can pass another process the current value of a list (for instance by sending it on a channel) and be sure it always sees the `right' value. i've found it particularly useful for lock-free concurrent access to caches implemented by hash tables (array of list of T), when the cache acts as a hint (as for instance in DNS implementation). as you say, you can always program a mutable list when you need one. ------------------- 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 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 VAA10712; Sat, 1 May 2004 21:25:50 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id VAA10795 for ; Sat, 1 May 2004 21:25:49 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i41JPkEV014944 for ; Sat, 1 May 2004 21:25:47 +0200 Received: from [192.168.1.200] (ppp116-155.lns1.syd2.internode.on.net [150.101.116.155]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i41JPdk2053574; Sun, 2 May 2004 04:55:40 +0930 (CST) Subject: Re: [Caml-list] Reading a large text file From: skaller Reply-To: skaller@users.sourceforge.net To: Richard Jones Cc: caml-list In-Reply-To: <20040501180508.GA16958@redhat.com> References: <20040428152813.47355.qmail@web60608.mail.yahoo.com> <20040501154351.GA5218@online.fr> <20040501180508.GA16958@redhat.com> Content-Type: text/plain Message-Id: <1083439539.20722.93.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 02 May 2004 05:25:39 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4093F9BA.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sourceforge:01 2004:99 2004:99 0400,:01 immutable:01 struct:01 mylist:01 mylist:01 immutable:01 preserving:01 9660:01 glebe:01 ocaml:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, 2004-05-02 at 04:05, Richard Jones wrote: > On Sat, May 01, 2004 at 11:43:51AM -0400, Rahul Siddharthan wrote: > The short answer is no, because in OCaml (unlike in LISP) lists are > immutable. > However, OCaml is a practical language and so allows you to create a > mutable cons structure if you so desire. eg: It can now do slightly better than that. It is possible to use the new 'private' keyword to *guard* your mutable list. module MList = struct type 'a mylist = private { head : 'a; mutable tail : 'a mylist option; } .. let splice a b = ...(* makes a new mylist of a @ b *) end Here, lists are immutable *publically*. However the splice function provides a concatenation of two ordinary lists into a mylist in 1 pass, with O(1) stack usage and the result is in forward order, not reversed. The list is still immutable! You can't modify it. The mutable field is only used during construction to append to the end, preserving the forward ordering. Its possible for C language implementations to do that kind of thing right now for actual Ocaml lists. But now you can play the game in Ocaml. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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 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 VAA11632; Sat, 1 May 2004 21:51:42 +0200 (MET DST) 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 VAA11955 for ; Sat, 1 May 2004 21:51:41 +0200 (MET DST) From: Alain.Frisch@ens.fr Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i41JpfSH004187 for ; Sat, 1 May 2004 21:51:41 +0200 Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.12.10/1.01.28121999) with ESMTP id i41JpeKx034621 ; Sat, 1 May 2004 21:51:40 +0200 (CEST) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.12.3/jb-1.1) id i41JpcTw029142 ; Sat, 1 May 2004 21:51:39 +0200 (MET DST) X-Authentication-Warning: clipper.ens.fr: frisch owned process doing -bs Date: Sat, 1 May 2004 21:51:38 +0200 (MET DST) X-X-Sender: frisch@clipper.ens.fr Reply-To: Alain.Frisch@ens.fr To: skaller cc: caml-list Subject: Re: [Caml-list] Reading a large text file In-Reply-To: <1083439539.20722.93.camel@pelican.wigram> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Miltered: at concorde with ID 4093FFCD.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; alain:01 frisch:01 caml-list:01 struct:01 mylist:01 mylist:01 immutable:01 struct:01 mutability:01 deconstruct:01 alain:01 mutable:01 mutable:01 sig:01 constructors:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On 2 May 2004, skaller wrote: > It can now do slightly better than that. It is possible to use > the new 'private' keyword to *guard* your mutable list. > > module MList = struct > type 'a mylist = private { head : 'a; mutable tail : 'a mylist option; } > .. > let splice a b = ...(* makes a new mylist of a @ b *) > end > Here, lists are immutable *publically*. Not quite. First, the "private" keyword should be used only in the signature, not the structure, otherwise the implementation of the module has no special right. Something like: module M : sig type t = private *** end = struct type t = *** end Second, the client cannot create values of the "private" type. This is not related at all with the mutability of the fields. It can only deconstruct values (with pattern matching). So you have to expose constructors explicitly (splice is one of them, but you probably want a simple Cons). -- Alain ------------------- 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 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 WAA14053; Sat, 1 May 2004 22:40:19 +0200 (MET DST) 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 WAA14290 for ; Sat, 1 May 2004 22:40:18 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i41KeFSH013023 for ; Sat, 1 May 2004 22:40:16 +0200 Received: from [192.168.1.200] (ppp116-155.lns1.syd2.internode.on.net [150.101.116.155]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i41Ke9k2064491; Sun, 2 May 2004 06:10:10 +0930 (CST) Subject: Re: [Caml-list] Reading a large text file From: skaller Reply-To: skaller@users.sourceforge.net To: Alain.Frisch@ens.fr Cc: caml-list In-Reply-To: References: Content-Type: text/plain Message-Id: <1083444008.20722.135.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 02 May 2004 06:40:08 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 40940B2F.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sourceforge:01 2004:99 alain:01 frisch:01 struct:01 mylist:01 mylist:01 immutable:01 struct:01 immutable:01 mutability:01 deconstruct:01 val:01 val:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, 2004-05-02 at 05:51, Alain.Frisch@ens.fr wrote: > On 2 May 2004, skaller wrote: > > > It can now do slightly better than that. It is possible to use > > the new 'private' keyword to *guard* your mutable list. > > > > module MList = struct > > type 'a mylist = private { head : 'a; mutable tail : 'a mylist option; } > > .. > > let splice a b = ...(* makes a new mylist of a @ b *) > > end > > Here, lists are immutable *publically*. > > Not quite. > > First, the "private" keyword should be used only in the signature, not the > structure, otherwise the implementation of the module has no special > right. Something like: > > module M : > sig type t = private *** end > = > struct type t = *** end Thanks for the correction. Also note I chose a *really bad name* when I called it 'splice': the intent was to construct a new list as stated, so I should have just called it 'concat'. Of course you could make a list with an actual splice mutator, but then it wouldn't be immutable. > Second, the client cannot create values of the "private" type. This is > not related at all with the mutability of the fields. It can only > deconstruct values (with pattern matching). Right. Well stated. Hmm .. module M : sig ?? type 'a t = private 'a list val uniq_cons: 'a t -> 'a -> 'a list val empty: unit -> 'a list end = struct type 'a t = 'a list let uniq_cons lst a = if List.mem a lst then lst else a::lst let empty () = [] end ;; ;; Syntax error: 'end' expected, the highlighted 'sig' might be unmatched Arggg.. what's wrong here? It has nothing to do with either private or type variables, and the above sig fails immediately in a module type statement too. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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 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 XAA16763; Sat, 1 May 2004 23:11:52 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA16462 for ; Sat, 1 May 2004 23:11:51 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i41LBmEV027993 for ; Sat, 1 May 2004 23:11:50 +0200 Received: from [192.168.1.200] (ppp116-155.lns1.syd2.internode.on.net [150.101.116.155]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i41LBhk2069583 for ; Sun, 2 May 2004 06:41:44 +0930 (CST) Subject: [Caml-list] Private types From: skaller Reply-To: skaller@users.sourceforge.net To: caml-list In-Reply-To: <1083444008.20722.135.camel@pelican.wigram> References: <1083444008.20722.135.camel@pelican.wigram> Content-Type: text/plain Message-Id: <1083445902.20722.149.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 02 May 2004 07:11:43 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 40941294.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; sourceforge:01 ahh:01 val:01 val:01 struct:01 endline:01 pelican:01 mnt:99 flx:01 9660:01 glebe:01 ocaml:01 sig:01 int:01 nsw:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Ahh, well this works: module type M_t = sig type 'a t = private { x: 'a list } val uniq_cons: 'a t -> 'a -> 'a t val empty: unit -> 'a t end module M : M_t = struct type 'a t = { x : 'a list } let uniq_cons lst a = if List.mem a lst.x then lst else { x = a::lst.x } let empty () = { x = [] } end let x = M.empty () let x = M.uniq_cons x 1 let x = M.uniq_cons x 1 let x = M.uniq_cons x 2 let print { M.x=x } = print_endline ( "[" ^ String.concat "," (List.map string_of_int x) ^ "]" ) ;; print x ;; [skaller@pelican] /mnt/user2/work/flx>ocaml xx.ml [2,1] -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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 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 XAA17319; Sat, 1 May 2004 23:33:58 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA17833 for ; Sat, 1 May 2004 23:33:57 +0200 (MET DST) From: Alain.Frisch@ens.fr Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i41LXuEV030452 for ; Sat, 1 May 2004 23:33:56 +0200 Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.12.10/1.01.28121999) with ESMTP id i41LXuKx081679 ; Sat, 1 May 2004 23:33:56 +0200 (CEST) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.12.3/jb-1.1) id i41LXsGK003425 ; Sat, 1 May 2004 23:33:54 +0200 (MET DST) X-Authentication-Warning: clipper.ens.fr: frisch owned process doing -bs Date: Sat, 1 May 2004 23:33:54 +0200 (MET DST) X-X-Sender: frisch@clipper.ens.fr Reply-To: Alain.Frisch@ens.fr To: skaller cc: caml-list Subject: Re: [Caml-list] Reading a large text file In-Reply-To: <1083444008.20722.135.camel@pelican.wigram> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Miltered: at nez-perce with ID 409417C4.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; alain:01 frisch:01 caml-list:01 arggg:01 alain:01 htmlman:01 ocaml:01 caml:01 equation:01 wrote:03 ens:06 type:07 type:07 manual:07 manual:07 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On 2 May 2004, skaller wrote: > ?? type 'a t = private 'a list > > Arggg.. what's wrong here? As stated in the manual, "private" can only be applied to the type *representation* (sum type, record type), not the type equation. http://caml.inria.fr/ocaml/htmlman/manual021.html -- Alain ------------------- 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 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 JAA10343; Fri, 14 May 2004 09:15:57 +0200 (MET DST) 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 JAA10286 for ; Fri, 14 May 2004 09:15:56 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i4E7FtSH009155; Fri, 14 May 2004 09:15:55 +0200 Received: from tintin.inria.fr (tintin.inria.fr [128.93.24.126]) by pauillac.inria.fr (8.7.6/8.7.3) with SMTP id JAA10461; Fri, 14 May 2004 09:15:54 +0200 (MET DST) Date: Fri, 14 May 2004 09:15:54 +0200 From: Maxence Guesdon To: sejourne kevin , caml-list@inria.fr Subject: Re: [Caml-list] [OcamlDoc] langage support. Message-Id: <20040514091554.6b0ea8e8@tintin.inria.fr> In-Reply-To: <20040501160024.1862.qmail@web41905.mail.yahoo.com> References: <20040501154351.GA5218@online.fr> <20040501160024.1862.qmail@web41905.mail.yahoo.com> Organization: INRIA X-Mailer: Sylpheed version 0.9.10claws (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 40A4722B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; maxence:01 guesdon:01 maxence:01 guesdon:01 caml-list:01 ocamldoc:01 2004:99 ocamldoc:01 evry:01 wrote:03 langage:04 langage:04 let:04 feature:07 cest:07 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sat, 1 May 2004 18:00:24 +0200 (CEST) sejourne kevin wrote: > Hi evrybody! > > Is there a way in Ocamldoc to make multilingual > documentation ? I think of something like that : > > (** > [En] Reverse a list. > [Fr] Retourne une liste. > [Es] ... > *) > Let rev = List.rev ;; > > And generate documentation file in evry langage use in > the code? No there is no such feature. You can add it yourself in a custom generator by handling @fr, @en, @es, ..., tags. Hope this helps, -- Maxence Guesdon ------------------- 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 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 HAA15026; Mon, 17 May 2004 07:28:44 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id HAA16175 for ; Mon, 17 May 2004 07:28:42 +0200 (MET DST) Received: from plover.csun.edu (plover.csun.edu [130.166.1.24]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4H5SfEV005080 for ; Mon, 17 May 2004 07:28:41 +0200 Received: from puffin.csun.edu (puffin.csun.edu [130.166.1.21]) by plover.csun.edu (MOS 3.4.6-GR) with ESMTP id BDQ97893; Sun, 16 May 2004 22:28:37 -0700 (PDT) Received: from [10.0.0.220] (cpe-24-31-48-47.socal.rr.com [24.31.48.47]) by puffin.csun.edu (MOS 3.4.4-GR) with ESMTP id BTF32688 (AUTH eric); Sun, 16 May 2004 22:28:35 -0700 (PDT) In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v613) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Message-Id: <0604BD51-A7C3-11D8-B8C2-000A95A1E69A@csun.edu> Content-Transfer-Encoding: quoted-printable Cc: caml-list@inria.fr From: Eric Stokes Subject: Re: [Caml-list] Reading a large text file Date: Sun, 16 May 2004 22:28:26 -0700 To: =?ISO-8859-1?Q?Andr=E9_Luiz_Moura?= X-Mailer: Apple Mail (2.613) X-Miltered: at nez-perce with ID 40A84D89.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 buffer:01 slower:01 digging:01 appending:01 appending:01 caml-list:01 implemented:01 seus:99 amigos:99 bug:01 faq:01 faq:01 beginner's:01 beginners:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk If you don't care about line breaks you might try Buffer.add_channel.=20 This should perform close to O(1) for the append operations, and it will bypass the call to=20= input_line, which I have found to be an order of magnitude slower than the read system call. You=20= can always break the lines up later. On May 1, 2004, at 7:03 AM, Brian Hurt wrote: > > I'm still digging through a serious backlog of email, so your question=20= > may > have already been answered. If so, ignore this. > > But what I'm guessing is happening is that you are appending (adding = to > the end of) your list, and that this is what is killing you. To add = an > element to the *end* of a list, Ocaml has to completely reallocate the > entire list- turning what you might think is an O(1) operation into an > O(n) operation. > > The solution to this is to build the list backwards- instead of adding > things to the end of the list, add them to the begining. Then, when > you're done, just reverse the list using List.rev. > > Lets look at the example of just reading the lines from a file and=20 > making > a list of them. This code is bad: > > let readfile chan =3D > let rec loop lst =3D > try > loop (lst @ [ (input_line chan) ]) > with > | End_of_file -> lst > in > loop [] > ;; > > It works, but to read n lines requires O(n^2) work, because the @ has=20= > to > reallocate the entire list every iteration. Worse yet it isn't tail > recursive (a recursive call inside a try/catch isn't a tail call). > > A better implementation of this would be: > let readfile chan =3D > let rec loop rlst =3D > let line, eof =3D > try > (input_line chan), false > with > | End_of_file -> "", true > in > if not eof then > loop (line :: rlst) > else > List.rev rlst > in > loop [] > ;; > > Now, the first thing to notice is that we're using the :: operator=20 > (which > is O(1)), not the @ operator (which is O(n))- we're prepending things=20= > onto > the list, not appending them. We're building up the list backwards,=20= > and > then, when we hit the end of the file, reversing the entire list. =20 > This is > a standard pattern in Ocaml. > > The second thing to notice is that the recursive call has been hoisted=20= > up > out of the try/catch block. We've introduced a new boolean flag to=20 > note > when we've hit the end of the file- catching the exception simply sets=20= > the > flag to true. So now our function is tail recursive, and operates in > constant stack space. > > Brian > > On Wed, 28 Apr 2004, Andr=E9 Luiz Moura wrote: > >> Hi List, >> >> I wrote an OCaml function to read a text file with a million of lines=20= >> with five separate columns for spaces. I based myself on previous=20 >> messages of Caml-list, but however the work is taking time frightful=20= >> (many minutes). >> This function written in C, for example, does not take more than 4=20 >> seconds. >> >> I am executing the program in a PC Pentium III of 128 MB of RAM under=20= >> Windows platform. How would be implemented the function to decide=20 >> this problem? >> >> File format: >> [attributes] [boundary marker] >> >> Thanks, >> >> Andr=E9 >> >> >> >> >> >> >> --------------------------------- >> Yahoo! Messenger - Fale com seus amigos online. Instale agora! > > --=20 > "Usenet is like a herd of performing elephants with diarrhea --=20 > massive, > difficult to redirect, awe-inspiring, entertaining, and a source of > mind-boggling amounts of excrement when you least expect it." > - Gene Spafford > Brian > > ------------------- > To unsubscribe, mail caml-list-request@inria.fr Archives:=20 > http://caml.inria.fr > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ:=20 > http://caml.inria.fr/FAQ/ > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > ------------------- 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