polyadic / funcky

Funcky is a Functional Library for C#
https://polyadic.github.io/funcky
Apache License 2.0
19 stars 3 forks source link

Specialized Partition for `IEnumerable<Either<Left, Right>>` #732

Closed Mafii closed 1 year ago

Mafii commented 1 year ago

That would be really useful, as:

var results = enumerable.Select(MethodReturningEither).Materialize(); // Materialize only needed for select many's after
var rights = results.SelectMany(e => e.RightOrNone().ToEnumerable()); // <- just really verbose for a partition
var lefts = results.SelectMany(e => e.LeftOrNone().ToEnumerable());

expected API:

var (lefts, rights) = enumerable.Select(MethodReturningEither).Partition()
bash commented 1 year ago

It already is