Created
November 4, 2020 05:40
-
-
Save banacorn/09ef2906831579116ef147a7ea78ae1e 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
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 | |
done; | |
!i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment