Skip to content
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

How exactly grouping work? #56

Closed
ghost opened this issue Jul 18, 2022 · 1 comment
Closed

How exactly grouping work? #56

ghost opened this issue Jul 18, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 18, 2022

I have a set of 4-tuples and would like to group them based on their third position and an extra condition on forth position. For instance:

A = [(1,5,2,5), (,12,5,9,6), (7,5,2,6), (11,5,2,5), (8,5,9,6), (3,5,3,6), (7,5,9,6), (1,5,3,6), (1,5,3,8), (2,5,3,6), (1,5,3,7), (1,4,3,6), (8,5,9,7), (3,5,3,8), (7,2,9,6)]
Third = [2,9,3 ] 
forth_con = [5,6]
@andyferris
Copy link
Member

So to group by the third element you could use group(x -> x[3], A).

Depending on what you want, you could group by a combination of the 3rd/4th keys with group(x -> (x[3], x[4]), A) or you could do it nested like group.(x -> x[4], group(x -> x[3], A)). (Oh how I do like that Dictionary can broadcast!)

Lastly, Discourse, Slack or Zulip might be better places to go for Q&A - you're likely to get faster responses, and GitHub is more for development issues.

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

No branches or pull requests

1 participant