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

Add unique!(f, itr) #28415

Closed
fredrikekre opened this issue Aug 2, 2018 · 8 comments
Closed

Add unique!(f, itr) #28415

fredrikekre opened this issue Aug 2, 2018 · 8 comments
Labels
collections Data structures holding multiple items, e.g. sets good first issue Indicates a good issue for first-time contributors to Julia

Comments

@fredrikekre
Copy link
Member

fredrikekre commented Aug 2, 2018

We have a unique(f, itr):

  unique(f, itr)

  Returns an array containing one value from itr for each unique value produced by f applied to
  elements of itr.

but no corresponding in-place version, would be nice to have. See #20619

@fredrikekre fredrikekre added good first issue Indicates a good issue for first-time contributors to Julia collections Data structures holding multiple items, e.g. sets labels Aug 2, 2018
@bvsravikiran
Copy link

Can I work on this issue?

@fredrikekre
Copy link
Member Author

fredrikekre commented Aug 3, 2018

Yes, anyone can work on any issue.

@deepaknalore
Copy link

@bvsravikiran If you are not working on it. I would like to pick it up

@bvsravikiran
Copy link

bvsravikiran commented Aug 17, 2018 via email

@shaktee
Copy link

shaktee commented Aug 18, 2018

Yikes. I was unaware that someone was working on this. I had already done this because I needed it. So, I created a pull request for it #28737

@shaktee
Copy link

shaktee commented Aug 18, 2018

If it is not the best implementation, please feel free to discard the pull request. (But, I would appreciate a commentary on the things that need improvement.)

@raghav9-97
Copy link
Contributor

If I am understanding it correctly, the return values of unique!(f, itr) does not really care about original order of occurrence.As it is also clear from the documentation of unique (f itr) :

unique(f, itr)

Returns an array containing one value from itr for each unique value produced by f applied to elements of itr.

Ex- A = [1,-1,3,-3,5,-5]

The unique!(f, itr) can generate -1,-3,-5 (if sort!(A) and _groupedunique!() like function applied) as well as 1,3,5 if order of occurence is necessary.

@StefanKarpinski
Copy link
Member

I think we generally want to leave the elements in their original order. There's no reason not to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
collections Data structures holding multiple items, e.g. sets good first issue Indicates a good issue for first-time contributors to Julia
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants