From 1ab69bfb730ebad450024918a43580e4aeb0d56d Mon Sep 17 00:00:00 2001 From: Estevan Castilho Date: Sat, 24 Oct 2026 02:47:52 +0000 Subject: Steal a `filter_map` implementation from Karuta --- lib/Utilities.ml | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/Utilities.ml') diff --git a/lib/Utilities.ml b/lib/Utilities.ml index 8f278a3..8b6b08e 100644 --- a/lib/Utilities.ml +++ b/lib/Utilities.ml @@ -86,6 +86,12 @@ module FingerTree = struct let join ss sep = BatFingerTree.print ~first:"" ~last:"" ~sep BatIO.nwrite |> Fun.flip BatIO.to_string ss + + let filter_map f = + BatFingerTree.fold_left + (fun acc elem -> + match f elem with None -> acc | Some result -> BatFingerTree.snoc acc result) + BatFingerTree.empty end module Atomic = struct -- cgit v1.2.3