Add min and max helper functions#11
Conversation
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)
|
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. |
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. |
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?