Documentation ¶
Overview ¶
Package iters contains utility functions that one might expect to find in the stock slices and maps packages. Functions starting with the word Slice receive an iter.Seq, and functions starting with the word Map receive an iter.Seq2.
Index ¶
- func Filter[T any](seq iter.Seq[T], predicate func(T) bool) iter.Seq[T]
- func Filter2[K comparable, V any](seq iter.Seq2[K, V], predicate func(K, V) bool) iter.Seq2[K, V]
- func MapTransform[K comparable, V, T any](src iter.Seq2[K, V], f func(K, V) T) iter.Seq[T]
- func MapTransform2[K comparable, V any, K2 comparable, V2 any](src iter.Seq2[K, V], f func(K, V) (K2, V2)) iter.Seq2[K2, V2]
- func SliceSelectFirst[T any](items iter.Seq[T], predicate func(T) bool) (T, bool)
- func SliceTransform[T, U any](src iter.Seq[T], f func(T) U) iter.Seq[U]
- func SliceTransform2[T any, K comparable, V any](src iter.Seq[T], f func(T) (K, V)) iter.Seq2[K, V]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
Filter returns a new sequence based on seq consisting only of those items where predicate returns true.
func Filter2 ¶
Filter2 returns a new sequence based on seq consisting only of those pairs of items where predicate returns true.
func MapTransform ¶
MapTransform applies a function f to each key-value pair in a source sequence and returns a sequence of the results.
func MapTransform2 ¶
func MapTransform2[K comparable, V any, K2 comparable, V2 any]( src iter.Seq2[K, V], f func(K, V) (K2, V2), ) iter.Seq2[K2, V2]
MapTransform2 applies a function f to each key-value pair in a source sequence and returns a sequence of key-value results.
func SliceSelectFirst ¶
SliceSelectFirst returns the first item from the sequence for which the predicate returns true. If no item is found, then it returns a default value and false.
func SliceTransform ¶
SliceTransform applies a function f to each item in a source sequence and returns a sequence of the results.
func SliceTransform2 ¶
SliceTransform2 applies a function f to each item in a source sequence and returns a sequence of key-value results.
Types ¶
This section is empty.