diff options
author | Joris | 2020-02-13 18:54:18 +0100 |
---|---|---|
committer | Joris | 2020-02-15 10:59:25 +0100 |
commit | 7a01b001ccc4a7bda3da92486903540e3f9754fd (patch) | |
tree | fbe269faa319fd7f21049612f8a62c0c169f369e /src/arrayUtils.ml | |
parent | 8328c11ac6706e3adf9b09877c02897132b8927a (diff) |
Set up bucklescript
Diffstat (limited to 'src/arrayUtils.ml')
-rw-r--r-- | src/arrayUtils.ml | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/arrayUtils.ml b/src/arrayUtils.ml new file mode 100644 index 0000000..75319d8 --- /dev/null +++ b/src/arrayUtils.ml @@ -0,0 +1,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") |