-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
add max
to gleam/list
#769
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Very useful.
I'm wondering if we really need both, given one is the the other inverted. It's be like having a list.filter
and a list.filter_not
or such.
Are there any other names we might want to consider?
Yeah I thought about this, and eventually decided that keeping both is reasonable - here's my train of thoughts
Happy to amend it if you have ideas though! Thanks for the prompt response. |
Good reasoning, thank you. Let's move forwards with just |
excellent point that it's hard to remove things! Removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!!
Inspired by my advent of code 2024 experiences. I often find myself reinventing
list.min
andlist.max
withfold
andreduce
, so I thought maybe it'd be nice to just promote these.PR Adds
list.min
andlist.max
togleam/list
.Like the name suggests, it returns the max/min element in the list, using the passed in comparator. These are slightly higher level abstractions than
reduce
as it takes in comparator functions, which can help with ergonomics at many places.