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
best and fastest way to read lines from a file?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-10-02 (21:16)
From: David Allsopp <dra-news@m...>
Subject: RE: [Caml-list] best and fastest way to read lines from a file?
> A little weird to see such inherently functional construct as fold
implemented imperatively. But it's fine with me, as long as it does the job.
> wonder, though, how would the performance of a line counter based on your
code compare with the one suggested by Brian. 

It's faster, though only slightly - I was going to post an imperative
solution earlier, too. Even in Ocaml, a recursive call (tail or otherwise)
has some costs not present in a simple loop. However, I don't agree that
it's more natural - "ugly" is more the word I'd use!