fsprojects / FSharp.Control.TaskSeq

A computation expression and module for seamless working with IAsyncEnumerable<'T> as if it is just another sequence
MIT License
91 stars 7 forks source link

Implement `max|min`, `maxBy|minBy` and `maxByAsync|minByAsync` #221

Closed abelbraaksma closed 8 months ago

abelbraaksma commented 8 months ago

Part of the push for good coverage of surface area functions, see #208. This implements min, max, minBy, maxBy, minByAsync and maxByAsync. Each of these behave exactly like their Seq counterparts:

The xml doc blibs have been taken from seq.fs and modified a bit for readability and applicability to TaskSeq.

The signatures are as follows:

static member max: source: TaskSeq<'T> -> Task<'T> when 'T: comparison
static member max: source: TaskSeq<'T> -> Task<'T> when 'T: comparison

static member maxBy: projection: ('T -> 'U) -> source: TaskSeq<'T> -> Task<'T> when 'U: comparison
static member minBy: projection: ('T -> 'U) -> source: TaskSeq<'T> -> Task<'T> when 'U: comparison

static member maxByAsync: projection: ('T -> #Task<'U>) -> source: TaskSeq<'T> -> Task<'T> when 'U: comparison
static member minByAsync: projection: ('T -> #Task<'U>) -> source: TaskSeq<'T> -> Task<'T> when 'U: comparison

TODO list:

abelbraaksma commented 8 months ago

Tests I'll do tomorrow.

abelbraaksma commented 8 months ago

This is ready to be merged.