caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jon Kleiser <jon.kleiser@ceres.no>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: [Caml-list] Is there a way to abort Stream.iter ?
Date: Fri, 12 May 2017 14:34:25 +0000	[thread overview]
Message-ID: <2490F692-502C-408E-9E60-30216557DF15@mail.uio.no> (raw)

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

             reply	other threads:[~2017-05-12 14:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-12 14:34 Jon Kleiser [this message]
2017-05-13 12:24 ` Yaron Minsky
2017-05-13 12:25   ` Yaron Minsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2490F692-502C-408E-9E60-30216557DF15@mail.uio.no \
    --to=jon.kleiser@ceres.no \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).