tablecloth
tablecloth copied to clipboard
Add List.partitionMap
(* Partition into two lists, of potentially different type, using function
* `f`. Returns value in the first list for `Left` and second list for
* `Right`. *)
let partitionMap (items : 'c list) ~(f : 'c -> ('a, 'b) Either.t): ('a list * 'b list) =
TableclothList.foldRight
~initial:([], [])
~f:(fun (lefts, rights) item ->
match f item with
| Left a ->
(a :: lefts, rights)
| Right b ->
(lefts, b :: rights))
items