This commit is contained in:
Simon Cruanes 2021-02-25 12:59:56 -05:00
parent 1975c98025
commit 89d6feed98

View file

@ -530,7 +530,7 @@ let diagonal l =
diagonal [1;2;3] |> List.sort Stdlib.compare = [1, 2; 1, 3; 2, 3] diagonal [1;2;3] |> List.sort Stdlib.compare = [1, 2; 1, 3; 2, 3]
*) *)
let partition_filter_either f l = let partition_map_either f l =
let rec iter f l1 l2 l = match l with let rec iter f l1 l2 l = match l with
| [] -> List.rev l1, List.rev l2 | [] -> List.rev l1, List.rev l2
| x :: tl -> | x :: tl ->
@ -542,7 +542,7 @@ let partition_filter_either f l =
(*$R (*$R
let l1, l2 = let l1, l2 =
partition_filter_either (function partition_map_either (function
| n when n mod 2 = 0 -> CCEither.Left n | n when n mod 2 = 0 -> CCEither.Left n
| n -> CCEither.Right n | n -> CCEither.Right n
) [0;1;2;3;4] ) [0;1;2;3;4]