Created
March 28, 2017 17:54
-
-
Save ccorcos/a826b62cd329f0e1f95895816bdf5de3 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 nth l n = | |
if n < 0 then invalid_arg "List.nth" else | |
let rec nth_aux l n = | |
match l with | |
| [] -> failwith "nth" | |
| a::l -> if n = 0 then a else nth_aux l (n-1) | |
in nth_aux l n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment