Documentation
¶
Overview ¶
Package itz implements additional utilities for Go iterators.
This library seeks to be aligned with patterns and naming used in the standard library such as the signatures in the `slices` package.
Index ¶
- func Append[T any](it iter.Seq[T], x T) iter.Seq[T]
- func Chunk[T any](it iter.Seq[T], n int) iter.Seq[[]T]
- func Chunk2[T, V any](it iter.Seq2[T, V], n int) iter.Seq[[]Tuple[T, V]]
- func Concat[T any](seqs ...iter.Seq[T]) iter.Seq[T]
- func Concat2[T, V any](seqs ...iter.Seq2[T, V]) iter.Seq2[T, V]
- func Filter[T any](it iter.Seq[T], pred func(T) bool) iter.Seq[T]
- func FlatMap[T, R any](it iter.Seq[iter.Seq[T]], fn func(T) R) iter.Seq[R]
- func Flatten[T any](it iter.Seq[iter.Seq[T]]) iter.Seq[T]
- func Map[T, R any](it iter.Seq[T], fn func(T) R) iter.Seq[R]
- func MapE[T, R any](it iter.Seq[T], fn func(T) (R, error)) iter.Seq2[R, error]
- func MapOption[T, R any](it iter.Seq2[T, error], fn func(T) R) iter.Seq2[R, error]
- func Pop[T any](it iter.Seq[T]) (fst T, ok bool)
- func Take[T any](it iter.Seq[T], n int) iter.Seq[T]
- type Tuple
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chunk ¶
Chunk is the equivalant of slices.Chunk, but for iterators.
func Concat ¶
Concat composes iterators together in the provided order.
This is similar to Python's `itertools.chain(*iterables)`.
func Filter ¶
Filter returns an iterator yielding all elements that the predicate returns truthy for.
func FlatMap ¶
FlatMap flattens a nested iterator and applies a transformation function.
Friendly reminder: Go is not a functional programming language ;)
func MapE ¶
MapE creates a new iterator with each element transformed by the provided, falable function.
func MapOption ¶
MapOption iterates over a fallable iterator, stopping if an error is returned, but otherwise applies the transformation to each element.