let sub_list l n = let rec aux acc n l = if n = 0 then acc else match l with [] -> assert false | x::r -> aux (x::acc) (n-1) r in List.rev (aux [] n l)