Created
May 12, 2017 16:15
-
-
Save m-alvarez/e3095ec397c59d4dd46c1ae89ef00b91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exception Found_element of int | |
let find_first (p : int -> bool) (s : int Stream.t) = | |
try ( | |
Stream.iter (fun elt -> if p elt then raise (Found_element elt)) s; | |
None | |
) | |
with | |
Found_element elt -> Some elt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment