Documentation
¶
Overview ¶
Package iter provides utility functions for working with iterators.
Index ¶
- func Concat[Slice []T, T any](seqs ...Slice) iter.Seq[T]
- func ConcatIter[T any](iters ...iter.Seq[T]) iter.Seq[T]
- func Filter[T comparable](it iter.Seq[T], filterFn func(T) bool) iter.Seq[T]
- func ForEach[T any](it iter.Seq[T], fn func(int, T))
- func Map[T, R any](it iter.Seq[T], mapFn func(T) R) iter.Seq[R]
- func Reduce[T, R any](it iter.Seq[T], reducer func(acc R, cur T) R, init R) R
- func Shuffle[Slice []T, T any](seq Slice, swapFn func(i, j int)) iter.Seq[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Concat ¶
Concat receives an arbitrary number of slices and returns an iterator to iterate on them successively, in the order they are given.
func ConcatIter ¶
ConcatIter receives an arbitrary number of iterators and returns an iterator to iterate over the elements, in the order they are given.
func Filter ¶
Filter returns an iterator that contains the elements of `it` for which filterFn returns true.
func Map ¶
Map executes a user-supplied function on each element of the `it` and returns an iterator over modified elements.
func Reduce ¶
Reduce executes a user-supplied `reducer` function on each element of the iterator `it`, in order, passing in the return value from the calculation on the preceding element.
func Shuffle ¶
Shuffle receives a slice and a swap function. It returns an iterator over the slice shuffled elements.
NOTE: In order not to allocate extra memory, it shuffles given slice(array) in place. If you need the original slice(array) untouched, you can clone your slice using slices.Clone and then pass it as the argument.
Types ¶
This section is empty.