Skip to content

Commit 8dc4d5a

Browse files
committed
fix: overshoot, concat_map is only TRMC after 5.1
1 parent 9ebfbe1 commit 8dc4d5a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/core/CCList.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ let rec equal f l1 l2 =
404404
| [], _ | _, [] -> false
405405
| x1 :: l1', x2 :: l2' -> f x1 x2 && equal f l1' l2'
406406

407+
[@@@iflt 5.1]
408+
407409
let rec flat_map_kont f l kont =
408410
match l with
409411
| [] -> kont []
@@ -415,8 +417,6 @@ let rec flat_map_kont f l kont =
415417
let kont' tail = kont (append x tail) in
416418
flat_map_kont f l' kont'
417419

418-
[@@@iflt 4.14]
419-
420420
let[@inline] flat_map f l =
421421
match l with
422422
| [] -> []

tests/core/t_list.ml

+4
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,12 @@ t @@ fun () ->
216216
flat_map (fun x -> [ x + 1; x * 2 ]) [ 10; 100 ] = [ 11; 20; 101; 200 ]
217217
;;
218218

219+
219220
t @@ fun () -> List.length (flat_map (fun x -> [ x ]) (1 -- 300_000)) = 300_000
220221
;;
222+
t @@ fun () ->
223+
List.length (flat_map (fun _ -> 1 -- 300_000) (1 -- 2)) = 600_000
224+
;;
221225

222226
eq [ 1; 2; 2; 3; 3; 3 ]
223227
(flat_map_i (fun i x -> replicate (i + 1) x) [ 1; 2; 3 ])

0 commit comments

Comments
 (0)