From 60b3ab24656cfc88ddc80fc60a06b5710e97e34f Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Fri, 1 Dec 2023 15:01:06 -0500 Subject: [PATCH] fix for 4.08 --- src/core/CCList.ml | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/core/CCList.ml b/src/core/CCList.ml index 5184d16d..c3c73cda 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -105,7 +105,7 @@ let map f l = direct f direct_depth_default_ l let append l1 l2 = - let[@inline] safe l1 l2 = List.rev_append (List.rev l1) l2 in + let[@inline] safe l1 l2 = List.rev_append (List.rev l1) l2 in let rec direct i l1 l2 = match l1 with | [] -> l2 @@ -332,7 +332,7 @@ let rec equal f l1 l2 = let rec flat_map_kont f l kont = match l with | [] -> kont [] - | [x] -> + | [ x ] -> let x = f x in kont x | x :: l' -> @@ -342,25 +342,11 @@ let rec flat_map_kont f l kont = [@@@iflt 5.1] -let[@inline] flat_map f l = match l with +let[@inline] flat_map f l = + match l with | [] -> [] - | [x] -> f x - | x :: tl - let rec aux f l kont = - match l with - | [] -> kont [] - | x :: l' -> - let y = f x in - let kont' tail = - match y with - | [] -> kont tail - | [ x ] -> kont (x :: tail) - | [ x; y ] -> kont (x :: y :: tail) - | l -> kont (append l tail) - in - aux f l' kont' - in - aux f l Fun.id + | [ x ] -> f x + | x :: tl -> flat_map_kont f l Fun.id [@@@else_]