English version
Accueil     Ŕ propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis ŕ jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml ŕ l'adresse ocaml.org.

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 (13:33)
From: Siegfried Gonzi <siegfried.gonzi@s...>
Subject: Re: [Caml-list] Reading a file
Michal Moskal wrote:

>>Why my Clean function is that fast is incomprehensible for me. 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.
>If you expand each line of megabyte file to list of characters -- it
>cannot be fast.

I will post the Clean snippet tomorrow. In the evening I will try other 
OCaml solutions. When I was first running my Clean program I couldn't 
believe it how fast it was; I was thinking of something like: "Clean is 
may be cheating me due to lazy evaluation, because as a return result I 
used the first list entry and I thought lazy evaluation just reads the 
first line of the 50MB file and nothing more". I did the test again but 
this time with estimating the length of the return list which ensures 
that the complete file becomes worked through.

Converting strings to list of chars is fast in Clean, as it seems. As 
far as I can remember I did the conversion ala:

[x\\x <-: y]

where y is the string (btw: '<-:' denotes "from array to list")

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