Skip to content

Add min and max helper functions#11

Open
skyjoe999 wants to merge 1 commit into
JimmyCushnie:masterfrom
skyjoe999:Min-Max-Helpers
Open

Add min and max helper functions#11
skyjoe999 wants to merge 1 commit into
JimmyCushnie:masterfrom
skyjoe999:Min-Max-Helpers

Conversation

@skyjoe999

@skyjoe999 skyjoe999 commented Jan 16, 2026

Copy link
Copy Markdown

Basic helper functions to find the min or max in an array based on some mapping function. (C# natively provides min and max functions but they return the comparison value, not the original)

I'm a functional programming girlypop, sue me!

Currently would be useful for the placement code but really when are helper functions a bad thing?

Basic helper functions to find the min or max in an array based on some mapping function. (C# natively provides min and max functions but they only work on directly comparable values)
@JimmyCushnie

Copy link
Copy Markdown
Owner

Do I understand correctly that these are functionally equivalent to MinBy and MaxBy? But I think neither of these are available in Unity's horribly outdated .NET so it would be useful to have them in JUU anyway.

If so, I think the function names should be changed to the same as the not-yet-available .NET ones, and there should be a comment like

// These function identically to Enumerable.MinBy and Enumerable.MaxBy in .NET 6+. Unity doesn't have access to modern .NET yet, which is why we reimplement them here.

@skyjoe999

Copy link
Copy Markdown
Author

Do I understand correctly that these are functionally equivalent to MinBy and MaxBy?

They serve the same roll although they are not actually identical in function. (These return both item and value and allow for a seed value while the dot net version seems to return an optional and allows for custom comparison functions.)

Although honestly now that ive rewritten the code that inspired these three times, its really not that cumbersome/less readable to just write it by hand. So maybe just close this lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants