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 JAA00094; Fri, 23 May 2003 09:11:39 +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 JAA00057 for ; Fri, 23 May 2003 09:11:38 +0200 (MET DST) Received: from teutates.kfunigraz.ac.at (TEUTATES.kfunigraz.ac.at [143.50.129.26]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h4N7BbH23368 for ; Fri, 23 May 2003 09:11:37 +0200 (MET DST) Received: from localhost (localhost.localdomain [127.0.0.1]) by teutates.kfunigraz.ac.at (Postfix) with ESMTP id E32723D2223; Fri, 23 May 2003 09:11:35 +0200 (CEST) Received: from teutates.kfunigraz.ac.at ([127.0.0.1]) by localhost (teutates.kfunigraz.ac.at [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 27361-06; Fri, 23 May 2003 09:11:35 +0200 (CEST) Received: from stud.uni-graz.at (IGAM08AV.kfunigraz.ac.at [143.50.39.35]) by teutates.kfunigraz.ac.at (Postfix) with ESMTP id 87E213D2191; Fri, 23 May 2003 09:11:34 +0200 (CEST) Message-ID: <3ECDB8C4.2050704@stud.uni-graz.at> Date: Fri, 23 May 2003 07:59:32 +0200 From: Siegfried Gonzi Organization: Universitaet Graz User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204 X-Accept-Language: en-us MIME-Version: 1.0 To: Markus Mottl Cc: caml-list@inria.fr Subject: Re: [Caml-list] Reading a file 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> <20030520132032.GA9564@roke.freak> <3ECB189C.5090400@stud.uni-graz.at> <20030521091120.GA9455@fichte.ai.univie.ac.at> <3ECC6DD5.9050509@stud.uni-graz.at> <20030522102654.GA23001@fichte.ai.univie.ac.at> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at stud.uni-graz.at X-Spam: no; 0.00; siegfried:01 gonzi:01 stud:99 caml-list:01 semicolon:01 floats:01 foo:01 regex:01 regexp:01 ocaml:01 mottl:02 float:02 string:03 wrote:03 library:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Markus Mottl wrote: >You cannot just take one solution of one language and assume that it >is equally efficient or elegant in another language. This also heavily >depends on availability and functionality of libraries. E.g. there is no >"take_while" or "drop_while" in the OCaml standard library - you'd have >to write them yourself. > I got this version and I think I like it best (except for this single semicolon; may be C could get some punctuation hell-ideas from Ocaml): let map_on_lines ic f = | let lines = ref [] in | begin try while true do | let l = input_line ic in | lines := l :: !lines | done | with End_of_file -> close_in ic | end ; | List.rev_map f !lines | | let extract_floats reg userval l = | List.map | (function | | "n/a" | "nil" -> userval | | s -> float_of_string s) | (Str.split reg l) | | let main = | let ic = open_in "foo" in | map_on_lines ic | (extract_floats (Str.regexp ",") (-1.0)) The problem what I am now faced with is as follows: how to use it. Do I have to link against a regex.o library? There is no Readme in the additional libraay folder of Ocaml how to use regex in Ocaml programs. Regards, S. Gonzi ------------------- 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