acc, List.rev res
;;
+let filter_map_monad f acc l =
+ let acc, res =
+ List.fold_left
+ (fun (acc, res) t ->
+ match f acc t with
+ | acc, None -> acc, res
+ | acc, Some x -> acc, x::res)
+ (acc,[]) l
+ in
+ acc, List.rev res
+;;
+
let list_rev_map_filter f l =
let rec aux a = function
| [] -> a