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 MAA10978; Tue, 20 May 2003 12:50:09 +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 MAA10969 for ; Tue, 20 May 2003 12:50:08 +0200 (MET DST) Received: from psyche.kaba.or.jp (psyche.kaba.or.jp [202.249.19.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h4KAo6H27840 for ; Tue, 20 May 2003 12:50:07 +0200 (MET DST) Received: from mail.kaba.or.jp (cascade.kaba.or.jp [202.249.19.34]) by psyche.kaba.or.jp (Postfix) with ESMTP id 01CAF22A8F; Tue, 20 May 2003 19:50:05 +0900 (JST) Received: from WARP (dhcp04.kaba.or.jp [202.249.19.39]) by mail.kaba.or.jp (Postfix) with SMTP id EB41149A6C; Tue, 20 May 2003 19:50:04 +0900 (JST) Message-ID: <017c01c31ebd$66b695c0$2713f9ca@WARP> From: "Nicolas Cannasse" To: "Siegfried Gonzi" , References: <4.3.2.7.2.20030517225010.04b748a0@localhost> <4.3.2.7.2.20030519120753.04545700@localhost> <200305201007.17990.wolfgang.mueller2@uni-bayreuth.de> <3EC9EA84.3070404@stud.uni-graz.at> Subject: Re: [Caml-list] Reading a file Date: Tue, 20 May 2003 19:48:51 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 extlib:01 sourceforge:01 enum:01 char:01 ocaml:01 nicolas:01 exists:01 modules:02 string:03 converts:03 data:03 let:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Is there a better way in Ocaml to read a file line by line than via the > read_line function? You might want to use the ExtLib for this. You can look at the CVS here : http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ocaml-lib/ The code you need : ------------------------------- open ExtLib let e = input_enum my_file in let e = Enum.map my_conversion_function e in List.of_enum e (* will return you the mapped list without any rev done *) ------------------------------------- (You'll need the ExtList and the Enum modules for it) > Does one > know whether there exists a function in OCaml which converts a String to > a character-list? I use this construct in Clean then in order to extract > floating point numbers from that character list: ['1','.','2',...] and > store this floating point numbers via pattern matching in my result-list. you can use ExtString.enum to get a char Enumeration on your string. It is more efficient then to use it as an Enum, since you don't create any data structure to store the chars , but you still can get a list from it by doing List.of_enum. Nicolas Cannasse ------------------- 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