Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

TODO: GroupBy & GroupJoin #1

Closed
2 tasks done
luvies opened this issue Feb 10, 2019 · 1 comment
Closed
2 tasks done

TODO: GroupBy & GroupJoin #1

luvies opened this issue Feb 10, 2019 · 1 comment

Comments

@luvies
Copy link
Owner

luvies commented Feb 10, 2019

i have never fully understood group-by, even in SQL, so i'll need to get on that an implement these methods

luvies added a commit that referenced this issue Feb 28, 2019
@luvies luvies closed this as completed in b6b64a9 Feb 28, 2019
@luvies
Copy link
Owner Author

luvies commented Feb 28, 2019

I haven't mimicked the GroupBy method exactly, there's 1 overload that isn't implemented, and that's the one that takes in the key & result selector. This is because the only distinguishing property between a lambda that selects the element to use and the one that creates the result element is that the former has 1 parameter, and the second 2.

Having the groupBy function do different behaviour on this factor alone feels like it is very much open to weird behaviour if someone puts in a function with an unexpected number of arguments, so I have not done it. Instead, you should do:

Lazy.from(iterable).groupBy(e => e.key, e => e, e => e.elements);

The only difference to the Linq method is that you explicitly pass e => e instead of it being implicit, which I think is better for the library (since the explicit behaviour difference is clearer overall).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant