let rec get_nth (xs: string list)(n: int) : string = if n < 1 then failwith "n must be a positive integer >= 1" if n > List.length xs then failwith "n must be less than or equal to the length of the list" match xs with | [] -> failwith "the list cannot be empty" | z::zs -> if n = 1 then z else get_nth zs (n - 1)