Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] ocaml and large development projects
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-05-20 (10:50)
From: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] Reading a file
> 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 :

The code you need :
open ExtLib

let e = input_enum my_file in
let e = 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 Archives:
Bug reports: FAQ:
Beginner's list: