From c72b60fd6f13c13924108bd46aa756dd56582eb9 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sat, 20 Dec 2025 11:15:15 -0500 Subject: [PATCH] do simplify the code a bit closer to the original solution, too. Avoids a redundant `:= []`. --- src/core/CCList.ml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/CCList.ml b/src/core/CCList.ml index bf73d7a6..668d5c0a 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -821,14 +821,14 @@ let take_drop n l = (* fun idea from nojb in https://discuss.ocaml.org/t/efficient-implementation-of-list-split/17616/2 *) let[@tail_mod_cons] rec loop (res_drop : _ ref) n l = - match n, l with - | 0, _ -> - res_drop := l; - [] - | _, [] -> - res_drop := []; - [] - | _, x :: tl -> x :: loop res_drop (n - 1) tl + match l with + | [] -> [] + | x :: tl -> + if n = 0 then ( + res_drop := l; + [] + ) else + x :: loop res_drop (n - 1) tl in let res_drop = ref [] in let res_take = loop res_drop n l in