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() to Base? #1645

Closed
johnmyleswhite opened this issue Nov 30, 2012 · 9 comments
Closed

Add unique() to Base? #1645

johnmyleswhite opened this issue Nov 30, 2012 · 9 comments

Comments

@johnmyleswhite
Copy link
Member

I'd really like to have the unique() function be added to Base. Here's @JeffBezanson's one-liner for it:

unique(a) = elements(Set(a...))
@ViralBShah
Copy link
Member

Yes, we should have unique() with that one liner to begin with.

@JeffBezanson
Copy link
Sponsor Member

What about giving results in sorted order?

@johnmyleswhite
Copy link
Member Author

That would be even better.

@JeffBezanson
Copy link
Sponsor Member

In that case the one liner will not be sufficient :)

@StefanKarpinski
Copy link
Sponsor Member

unique(a) = sort!(elements(Set(a...)))?

@pao
Copy link
Member

pao commented Dec 4, 2012

Sorted only works if the type is ordered, though; unique is just as useful with types that are merely comparable.

@StefanKarpinski
Copy link
Sponsor Member

That's a really good point. If someone wants it sorted too, they can wrap it in sort!.

@johnmyleswhite
Copy link
Member Author

@pao's right: ditch the sorting.

@johnmyleswhite
Copy link
Member Author

Thanks!

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

5 participants