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
slices: add ContainsFunc function #39
Conversation
This PR (HEAD: 7554eb1) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/exp/+/417374 to see it. Tip: You can toggle comments from me using the |
Message from Ian Lance Taylor: Patch Set 1: Hold+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Ian Lance Taylor: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
slices/slices.go
Outdated
@@ -128,6 +128,12 @@ func Contains[E comparable](s []E, v E) bool { | |||
return Index(s, v) >= 0 | |||
} | |||
|
|||
// ContainsFunc reports whether at least one element in s | |||
// satisfies f(s[*]). | |||
func ContainsFunc[E comparable](s []E, f func(E) bool) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be E any
to match IndexFunc, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely correct, thank you!
This PR (HEAD: 8923cee) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/exp/+/417374 to see it. Tip: You can toggle comments from me using the |
Message from Ian Lance Taylor: Patch Set 2: -Hold (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Pavel Griaznov: Patch Set 3: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Brad Fitzpatrick: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Ian Lance Taylor: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Ian Lance Taylor: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
This PR (HEAD: 96a32b3) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/exp/+/417374 to see it. Tip: You can toggle comments from me using the |
Message from Pavel Griaznov: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Ian Lance Taylor: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
This PR (HEAD: b7f6091) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/exp/+/417374 to see it. Tip: You can toggle comments from me using the |
Message from Pavel Griaznov: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Ian Lance Taylor: Patch Set 5: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Gopher Robot: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Gopher Robot: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Gopher Robot: Patch Set 5: TryBot-Result-1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Ian Lance Taylor: Patch Set 6: Patch Set 5 was rebased Outdated Votes:
Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Ian Lance Taylor: Patch Set 6: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Gopher Robot: Patch Set 6: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Gopher Robot: Patch Set 6: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Ian Lance Taylor: Patch Set 6: Run-TryBot+1 Auto-Submit+1 Code-Review+2 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Message from Brad Fitzpatrick: Patch Set 6: Code-Review+2 Please don’t reply on this GitHub thread. Visit golang.org/cl/417374. |
Since we have Index, IndexFunc, and Contains functions, it's logical to have ContainsFunc function as well. Fixes #53983 Change-Id: I1237d43bd93927d38b51e3e9ce5386b9098049f7 GitHub-Last-Rev: b7f6091 GitHub-Pull-Request: #39 Reviewed-on: https://go-review.googlesource.com/c/exp/+/417374 Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
This PR is being closed because golang.org/cl/417374 has been merged. |
Since we have Index, IndexFunc, and Contains functions, it's logical to have ContainsFunc function as well.
Fixes #53983