View raw

1 (** List utilities not in the OCaml 5.2 stdlib. *) 2 3 let rec take n = function 4 | _ when n <= 0 -> [] 5 | [] -> [] 6 | x :: rest -> x :: take (n - 1) rest 7 8 let rec drop n = function 9 | l when n <= 0 -> l 10 | [] -> [] 11 | _ :: rest -> drop (n - 1) rest 12