-
Notifications
You must be signed in to change notification settings - Fork 58
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 gatherEquals function. #114
Conversation
I really like the idea of this function but I'm wondering how useful this is without allowing for a custom equality function. It seems to me that the only useful thing you can do with the output is to calculate how many copies of each element there are. (Please tell me if I am overlooking something here.) In that case maybe |
We actually use it in production ^^ It's both for counting the number of things, but we also give each element an index and render each section together. So it does have more uses then just counting them. Your arguments are valid, so I'm open to adding both |
How exactly are you using it? I think I can kind of see how you might be using it. Something like Is that right? Am I anywhere close? I also agree about adding |
Added The way we use it is that we get a list of purchased tickets from our backend. We want to summarize what you've bought (eg. 2 adult tickets, 1 child ticket), and if the user clicks "view details" we want to print a human readable description of each ticket as well. So while @pzp1997 would work, we would likely need to use For us, grouping the elements then counting and rendering seemed like the better option. |
Updated to return (a, List a) |
I have a backlog of work right now but I can review your updated code in a couple days if no one gets to it first. |
The code looks good to me. I havent run the tests yet to be 100% certain. I do notice two things in the documentation
Also, its just occurring to me that the names |
I agree with |
I think you need to add |
Great. Looks good to me too. Thanks @Skinney ! |
This is similar to
group
, except it groups all equal elements in a single sub-list. I'm open to change the name to something better.