On Mon, Apr 21, 2008 at 04:01:30PM -0400, Michael DiBernardo wrote:
> Yes, I was trying to avoid while loops / other iterative constructs,
> but I find that extremely difficult to do when dealing with I/O. Glad
> to know this is a common idiom, thanks for that.
At the end of the day, it's a programming language for getting stuff
done in, so I wouldn't be too precious about avoiding while loops.
There's a periodic discussion that happens on the lists about how to
read all lines from a file:
http://caml.inria.fr/pub/ml-archives/ocaml-beginners/2003/04/1f84bc1aa990459f9da\
2721e399dfcde.en.html
http://caml.inria.fr/pub/ml-archives/caml-list/2003/05/79e940406a290a4ae25b18228\
cd70133.en.html
http://caml.inria.fr/pub/ml-archives/caml-list/2004/04/5814f3200c451a4983ffb0111\
e7767c1.en.html
http://caml.inria.fr/pub/ml-archives/caml-list/2007/10/cb1c2bd7a37c8daf5a02672af\
2c2bf13.en.html
The answer is to use a while loop!
Rich.
--
Richard Jones
Red Hat