[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | briand@a... |
| Subject: | [Caml-list] Checking for eof |
Youa are actually looking for an eof exception.
Here is a code segment which demonstrates this nicely and won't blow
up the stack.
let readfile chan =
let rec loop rlst =
let line, eof =
try
(input_line chan), false
with
| End_of_file -> "", true
in
if not eof then
(
loop (line :: rlst);
)
else
List.rev rlst
in
loop []
;;
Brian