iter

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All added in v0.5.0

func All[E any](s Seq[E], f func(E) bool) bool

func Any added in v0.5.0

func Any[E any](s Seq[E], f func(E) bool) bool

func Count

func Count[E comparable](s Seq[E], value E) int

func CountFunc added in v0.5.0

func CountFunc[E any](s Seq[E], f func(E) bool) int

func Find added in v0.5.0

func Find[E any](s Seq[E], f func(E) bool) (result E, ok bool)

func Fold added in v0.5.0

func Fold[E, A any](s Seq[E], init A, f func(A, E) A) A

func ForEach

func ForEach[E any](s Seq[E], f func(E))

ForEach call f on each element in Seq.

func Index added in v0.5.0

func Index[E any](s Seq[E], f func(E) bool) (int, bool)

func IsSorted

func IsSorted[E cmp.Ordered](s Seq[E]) bool

func IsSortedFunc added in v0.5.0

func IsSortedFunc[E any](s Seq[E], f func(E, E) int) bool

func Max

func Max[E cmp.Ordered](s Seq[E]) (m E, hasElem bool)

func MaxFunc added in v0.5.0

func MaxFunc[E any](s Seq[E], f func(E, E) int) (m E, hasElem bool)

func Min

func Min[E cmp.Ordered](s Seq[E]) (m E, hasElem bool)

func MinFunc added in v0.5.0

func MinFunc[E any](s Seq[E], f func(E, E) int) (m E, hasElem bool)

func Reduce added in v0.5.0

func Reduce[E any](s Seq[E], f func(E, E) E) (result E, hasElem bool)

func Size added in v0.5.0

func Size[E any](s Seq[E]) int

func TryFold added in v0.5.0

func TryFold[E, A any](s Seq[E], init A, f func(A, E) (A, error)) (res A, err error)

func TryForEach added in v0.5.0

func TryForEach[E any](s Seq[E], f func(E) error) (err error)

TryForEach call f on each element in Seq, stopping at the first error and returning that error.

Types

type Seq added in v0.5.0

type Seq[E any] func(yield func(E) bool)

Seq is an iterator over sequences of individual values. When called as seq(yield), seq calls yield(v) for each value v in the sequence, stopping early if yield returns false.

see: https://github.com/golang/go/issues/61897

func Distinct added in v0.5.0

func Distinct[E comparable](s Seq[E]) Seq[E]

func Enumerate

func Enumerate[E any](s Seq[E]) Seq[Tuple[int, E]]

func Filter

func Filter[E any](s Seq[E], f func(E) bool) Seq[E]

Filter remove elements do not match predicate.

func FlatMap added in v0.5.0

func FlatMap[E, T any](s Seq[E], f func(E) Seq[T]) Seq[T]

func Flatten added in v0.5.0

func Flatten[E any](s Seq[Seq[E]]) Seq[E]

func Map

func Map[E, T any](s Seq[E], f func(E) T) Seq[T]

func Skip

func Skip[E any](s Seq[E], n int) Seq[E]

func Take

func Take[E any](s Seq[E], n int) Seq[E]

type Tuple added in v0.5.0

type Tuple[A, B any] struct {
	Left  A
	Right B
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL