-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed as not planned
Labels
Milestone
Description
Add a new function, slices.Set
which removes all duplicate elements in a slice.
Proposed Signature:
func Set[E comparable](s []E)
Usage:
i := []int{1, 2, 3, 1, 2, 3, 1, 4, 5, 6, 2, 1, 1, 2, 4, 7}
slices.Set(i) // i == []int{6, 3, 2, 4, 7, 1, 5} or i == []int{1, 2, 3, 4, 5, 6, 7}
The name slices.Set
from the data type Set, which holds unique values, without any particular order, slices.Set
might be confusing as a function name, other alternative is slices.Unique
.