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
Re: [Caml-list] Loop times
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-03-18 (15:21)
From: Florian Hars <hars@b...>
Subject: Re: [Caml-list] Loop times
Oliver Bandel wrote:
> What does this mean for such a version of reading a file
> linewise into a list of strings?

Nothing. I/O usually isn't CPU-bound.

You may argue that this idiom looks ugly nonetheless, but this is why 
you stow it away in some utility functions, called Textfile.iter and 
Textfile.fold (anyone round here who has not writeen these?).

So your code looks something like

let input_lines chan =
    List.rev (Textfile.fold (::) chan [])

or so, depending on how you order the arguments.

Yours, Florian.

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