Commits

Anonymous committed 8ec2ac6

+ Stream.map_filter

  • Participants
  • Parent commits 7ea11f1

Comments (0)

Files changed (1)

      )
     ;
 
+    value map_filter
+     : ! 'a 'b . ('a -> option 'b) -> t 'a -> t 'b
+     = fun f s -> Stream.from inner
+      where rec inner _streamarg =
+        match next_opt s with
+        [ None -> None
+        | Some x ->
+            match f x with
+            [ None -> inner _streamarg
+            | some_v -> some_v
+            ]
+        ]
+    ;
+
     value is_empty s =
       try (Stream.empty s; True)
       with [ Stream.Failure -> False ]