Documentation
¶
Index ¶
- func All[T any](source iterator.Iterator[T], predicate func(T) bool) bool
- func Any[T any](source iterator.Iterator[T], predicate func(T) bool) bool
- func Fold[T, U any](it iterator.Iterator[T], initial U, fn func(U, T) U) U
- func Product[T Number](it iterator.Iterator[T]) T
- func Reduce[T any](it iterator.Iterator[T], fn func(T, T) T) T
- func Sum[T Number](it iterator.Iterator[T]) T
- type Number
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fold ¶
Fold applies a function to each element of the iterator, threading an accumulator argument through the computation.
Example ¶
s := source.Slice([]int{1, 2, 3})
it := Fold[int, []int](s, []int{}, func(acc []int, x int) []int { return prependInt(acc, x) })
fmt.Println(it)
Output: [3 2 1]
Types ¶
type Number ¶
type Number interface {
constraints.Integer | constraints.Float
}
Number represents any number type that can be aggregated.
Click to show internal directories.
Click to hide internal directories.