TMC optimize List.flat_map

This commit is contained in:
tali 2024-01-30 19:05:35 -05:00
parent 7d4fa61935
commit 2d9aaff4ef
1 changed files with 9 additions and 4 deletions

View File

@ -20,11 +20,16 @@ module List = struct
include List
let flat_map f xs =
let rec iter acc = function
| [] -> rev acc
| x :: xs -> iter (rev_append (f x) acc) xs
let rec iter = function
| [] -> []
| x :: xs -> append_then_iter xs (f x)
[@@tail_mod_cons]
and append_then_iter xs = function
| [] -> iter xs
| y :: ys -> y :: append_then_iter xs ys
[@@tail_mod_cons]
in
iter [] xs
iter xs
end
include (val Logging.logs "Irc")