let rev_filter_map l ~f = let rec loop l accum = match l with | [] -> accum | hd :: tl -> match f hd with | Some x -> loop tl (x :: accum) | None -> loop tl accum in loop l []