aboutsummaryrefslogtreecommitdiff
path: root/src/arrayUtils.ml
blob: 75319d889210b35841b672948f991ce685be2ceb (plain)
1
2
3
4
5
6
7
8
let flatMap (f : 'a -> 'b option) (xs : 'a Js.Array.t) : 'b Js.Array.t =
  xs |> Js.Array.map f
  |> Js.Array.filter (fun maybe ->
         match maybe with Some _ -> true | None -> false)
  |> Js.Array.map (fun maybe ->
         match maybe with
         | Some x -> x
         | None -> Js.Exn.raiseError "Unexpected None")