-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: x/exp/xiter: add {All,Any,None}{,2} #67453
Comments
Presumably these would short circuit since Should this be (and likewise for |
Because none of these functions declare type parameters beyond those of Seq or Seq2, they could be expressed as methods of the named types Seq and Seq2: package iter
// All reports whether all elements of the sequence satisfy the predicate f.
func (Seq[E]) All(f func(E) bool) bool
func (Seq[E]) Any(f func(E) bool) bool // shorthand for !All(Negate(f))
func (Seq[E]) None(f func(E) bool) bool // shorthand for !Any(f) |
If |
iter.Seq is not an alias; generic aliases are not even part of the go1.23 spec. The discussion about whether it should have been an alias is just words after the fact. |
I'm here from #68945. (Thanks for connecting the two @seankhliao—I didn't see this when searching.) Given the existence of slices.Contains and slices.ContainsFunc, we could alternatively have (for consistency) func Contains[E comparable](seq Seq[E], e E) bool
func ContainsFunc[E any](seq Seq[E], func(e E) bool) bool
|
Proposal Details
Proposed to add below funcitons:
Same as seq2.
Different from
reduce
,fold
needs to provide an initial valueThe text was updated successfully, but these errors were encountered: