libguestfs: Ignore error: mkfs_btrfs: /dev/sda1: not enough free space.
[goaljobs-goals.git] / utils.ml
index 25fc740..43119ee 100644 (file)
--- a/utils.ml
+++ b/utils.ml
@@ -16,3 +16,10 @@ let sort_uniq ?(cmp = Pervasives.compare) xs =
   let xs = List.sort cmp xs in
   let xs = uniq ~cmp xs in
   xs
+
+let rec filter_map f = function
+  | [] -> []
+  | x :: xs ->
+    match f x with
+    | Some y -> y :: filter_map f xs
+    | None -> filter_map f xs