let split_n t_orig n =
if n <= 0 then
([], t_orig)
else
let rec loop n t accum =
if n = 0 then
(List.rev accum, t)
else
match t with
| [] -> (t_orig, []) (* in this case, t_orig = List.rev accum *)
| hd :: tl -> loop (n - 1) tl (hd :: accum)
in
loop n t_orig []