Skip to content

proposal: x/exp/xiter: add {All,Any,None}{,2} #67453

@leaxoy

Description

@leaxoy

Proposal Details

Proposed to add below funcitons:

-- func Fold[A, E any](s Seq[E], init A, f func(A, E) A) A--
// Remove Fold because original proposal's `Reduce` takes an initial value.

func All[E any](s Seq[E], f func(E) bool) bool {
    return Fold(s, true, func(x bool, e E) bool { return x && f(e) })
}

func Any[E any](s Seq[E], f func(E) bool) bool {
    return ...
}

func None[E any](s Seq[E], f func(E) bool) bool {
    return ...
}

Same as seq2.

Different from reduce, fold needs to provide an initial value

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions