diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Utilities.ml | 6 | ||||
| -rw-r--r-- | lib/Utilities.mli | 1 |
2 files changed, 7 insertions, 0 deletions
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 diff --git a/lib/Utilities.mli b/lib/Utilities.mli index 204fec3..f220b08 100644 --- a/lib/Utilities.mli +++ b/lib/Utilities.mli @@ -35,6 +35,7 @@ module FingerTree : sig val sequence : ('a, 'b) result BatFingerTree.t -> ('a BatFingerTree.t, 'b) result val foldm_left : ('a -> 'b -> ('a, 'e) result) -> 'a -> 'b BatFingerTree.t -> ('a, 'e) result val join : string BatFingerTree.t -> string -> string + val filter_map : ('a -> 'b option) -> 'a BatFingerTree.t -> 'b BatFingerTree.t end module Fun : sig |
