let rec splitAt n xs = match (n, xs) with
| 0, xs -> ([], xs)
| _, [] -> ([], [])
| n, x::xs -> let (xs', xs'') = splitAt (n - 1) xs in
(x::xs', xs'')