caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Is there a way to abort Stream.iter ?
@ 2017-05-12 14:34 Jon Kleiser
  2017-05-13 12:24 ` Yaron Minsky
  0 siblings, 1 reply; 3+ messages in thread
From: Jon Kleiser @ 2017-05-12 14:34 UTC (permalink / raw)
  To: caml-list

In my little program here <http://folk.uio.no/jkleiser/ocaml/read_vec.ml> I’m reading and processing a text file by doing this:

let process_lines lines =
  let start_time = Sys.time () in
  Stream.iter process_line lines;
  let finish_time = Sys.time () in
  Printf.printf "\nTime used: %f secs\n" (finish_time -. start_time)

. . . where the ‘lines’ input is coming from ‘(line_stream_of_channel in_channel)’.

Is there a way to abort the Stream.iter processing based on some condition detected by the ‘process_line’ function? Could it be done by throwing an exception? Maybe I should use something else than Stream.iter ?

/Jon

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-05-13 12:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-12 14:34 [Caml-list] Is there a way to abort Stream.iter ? Jon Kleiser
2017-05-13 12:24 ` Yaron Minsky
2017-05-13 12:25   ` Yaron Minsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).