Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from Dec 23, 2023

Conversation

abelbraaksma
Copy link
Member

@abelbraaksma abelbraaksma commented Dec 22, 2023

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:

  • raises on null input
  • raises if the input is the empty task sequence
  • returns the min or max of the input by using IComparable semantics (i.e.: when 'T: comparison)

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:

  • Implement TaskSeq.min
  • Implement TaskSeq.max
  • Implement TaskSeq.minBy
  • Implement TaskSeq.maxBy
  • Implement TaskSeq.minByAsync
  • Implement TaskSeq.maxByAsync

@abelbraaksma
Copy link
Member Author

Tests I'll do tomorrow.

@abelbraaksma
Copy link
Member Author

This is ready to be merged.

@abelbraaksma abelbraaksma merged commit 1d0c637 into main Dec 23, 2023
6 checks passed
@abelbraaksma abelbraaksma deleted the implement-max-min-maxby-minby branch December 23, 2023 18:51
Copy link
Member

@bartelink bartelink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done; the comments in the assertions are a key ingredient
It's not easy avoiding being cryptic!

@abelbraaksma abelbraaksma added topic: surface area Adds functions to the public surface area feature request New feature or enhancement request labels Dec 24, 2023
@abelbraaksma abelbraaksma added this to the v0.4.0 milestone Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or enhancement request topic: surface area Adds functions to the public surface area
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants