Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

One utility function commonly found in the standard libraries of other languages allows the retrieval of a minimal or maximal element. (A separate min_by is not necessary, as it can be achieved by Fun.flip-ping the comparator function.)

Currently the quick & dirty way to achieve this is sorting the list and taking the head element, but that is wasteful in terms of resources if only a single extreme element is needed to be found.

Is this be something you would consider adding to the library? If yes, I'll try to prepare and submit a PR with an implementation, tests and docs.

You must be logged in to vote

Replies: 1 comment · 1 reply

Comment options

I tend to use Iter.of_list l |> Iter.min_exn and the likes (here) but that's not a bad idea anyway to have that on lists.

You must be logged in to vote
1 reply
@isti115
Comment options

Thanks for the quick responses everywhere! 🙂
(And the awesome library in the first place as well! 😉)

I still don't fully understand the guiding principle in this codebase on deciding between having features duplicated across modules (maintenance burden) or relying on conversions between representations to use functions from other modules (potential performance tradeoff), so I'm not entirely sure when to suggest adding a function that already exists somewhere else to another module, but since this is not only just in a separate module, but in an entirely separate library, I think that it is worthwhile having a version in here as well. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.