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

I want to add a new Functions - Remove #171

Open
Luoxin opened this issue Sep 6, 2021 · 5 comments
Open

I want to add a new Functions - Remove #171

Luoxin opened this issue Sep 6, 2021 · 5 comments

Comments

@Luoxin
Copy link
Contributor

Luoxin commented Sep 6, 2021

I want to add remove,like:

listA := pie.Strings{"1", "2"}
listB := pie.Strings{"1", "3"}
      
// [ "2" ]
fmt.Println(listA.Remove(listB...))

In some scenarios, there will be a desire to weed out the data in slice A from the data in slice B

@Luoxin
Copy link
Contributor Author

Luoxin commented Sep 6, 2021

I have made some attempts
#172

@chocolacula
Copy link
Contributor

@elliotchance What is the actual status? I would be happy to add similar function with index based removing in Go idiomatic(but not perfect) way s = append(s[:idx], s[idx+1:]...) within. I guess behaviour described above is exactly the same as Intersect

@elliotchance
Copy link
Owner

Intersect creates a set of elements that exist in both sets. I believe what @Luoxin is talking about here is "except" which results in the elements that do not exist in another set.

Speaking more broadly, it would be nice to have a Set type in this library for dealing with unordered unique items where these kinds of operations make sense. Otherwise, union operations on non-unique elements can be ambiguous.

@chocolacula
Copy link
Contributor

Of course, Except

@chocolacula
Copy link
Contributor

Added in #194

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

3 participants