Skip to content

Conversation

@ursenzler
Copy link

Description

Added documentation and tests that maxBy/minBy return the first max/min element (Array, List, Seq).
Added tests that the first min/max element is returned (Array, List, Seq).
I wasn't able to add a test in CollectionModulesConsistency because I wasn't sure how to add it there because of the data generator.

!! I wasn't able to run the tests (fsx.exe not found in SDK 🤷) !!

I also cleaned up the exception docu on empty array/list/seq (once in the exceptions section, once as a remark).

I hope that helps 😃
Feel free to ignore, improve, change, take parts, ...

Fixes #19129

Checklist

  • Test cases added
  • Performance benchmarks added in case of performance changes
  • Release notes entry updated: does not apply

…nd minBy functions on List, Array, and Seq modules. Also cleaned-up duplicate "exception on empty" documentation.
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

❗ Release notes required

@ursenzler,

Caution

No release notes found for the changed paths (see table below).

Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format.

The following format is recommended for this repository:

* <Informative description>. ([PR #XXXXX](https://github.com/dotnet/fsharp/pull/XXXXX))

See examples in the files, listed in the table below or in th full documentation at https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html.

If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

You can open this PR in browser to add release notes: open in github.dev

Change path Release notes path Description
src/FSharp.Core docs/release-notes/.FSharp.Core/10.0.200.md No release notes found or release notes format is not correct

@ursenzler
Copy link
Author

@dotnet-policy-service agree

/// <summary>Returns the greatest of all elements of the list, compared via Operators.max on the function result.</summary>
///
/// <remarks>Raises <see cref="T:System.ArgumentException"/> if <c>list</c> is empty.</remarks>
/// <remarks>Returns the first maximal element of the list if there are multiple equal maximum elements.</remarks>
Copy link
Member

Choose a reason for hiding this comment

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

But we should also keep the remark about empty input (applies also to array)

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't exception documentation use <exception> instead of <remarks>?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, even better.

@github-project-automation github-project-automation bot moved this from New to In Progress in F# Compiler and Tooling Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

The documention about maxBy (Array, List, ...) should state that the first max value is returned.

3 participants