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

proposal: slices: Unique() #66247

Closed
antonsacred opened this issue Mar 11, 2024 · 1 comment
Closed

proposal: slices: Unique() #66247

antonsacred opened this issue Mar 11, 2024 · 1 comment
Labels
Milestone

Comments

@antonsacred
Copy link

Proposal Details

I propose to create function Unique with the definition:

// Unique replaces runs of equal elements with a single copy.
// Unique modifies the contents of the slice s and returns the modified slice,
// which may have a smaller length.
func Unique[S ~[]E, E comparable](s S) S {}

and yes, we already have Compact, but Compact can not filter items that are not consecutive.

Example of usage:

myslice := []int{1,2,1}
filteredslice := slises.Unique(myslice) // []int{1,2}

I have already created PR for this change #66231

@gopherbot gopherbot added this to the Proposal milestone Mar 11, 2024
@seankhliao
Copy link
Member

This was discussed in #47203 and #45955 and it is not something that we will do.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants