Skip to content

Instantly share code, notes, and snippets.



Created Nov 4, 2020
What would you like to do?
let first p xs =
let length = Array.length xs in
(* mutable aray index *)
let i = ref 0 in
(* there are no loop breaks in OCaml anyway *)
let break = ref false in
while not (!break) && !i < length do
if p (xs.(!i)) then break := true else i := (!i) + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment