seq2

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectMap

func CollectMap[K cmp.Ordered, V any](seq iter.Seq2[K, V]) map[K]V

CollectMap collects all elements of the sequence into a map.

func CollectSlice

func CollectSlice[K, V any](seq iter.Seq2[K, V]) []V

CollectSlice collects all elements of the sequence into a slice.

func Filter

func Filter[K, V any](seq iter.Seq2[K, V], f func(K, V) bool) iter.Seq2[K, V]

Filter returns a new sequence that contains only the elements of the original sequence that satisfy the filter function. The filter function should return true for elements that should be included in the new sequence.

func Map

func Map[InK, InV, OutV any](
	seq iter.Seq2[InK, InV],
	mapper func(InK, InV) OutV,
) iter.Seq[OutV]

Map returns a new sequence that contains the results of applying the mapper function to each element of the original sequence. The mapper function should return the new value for each element.

func Map2

func Map2[InK, InV, OutK, OutV any](
	seq iter.Seq2[InK, InV],
	mapper func(InK, InV) (OutK, OutV),
) iter.Seq2[OutK, OutV]

Map2 returns a new sequence that contains the result of applying the mapper function to each element of the original sequence. The mapper function should return a key-value pair for each element.

func Skip

func Skip[K, V any](seq iter.Seq2[K, V], num int) iter.Seq2[K, V]

Skip returns a new sequence that skips the first num elements of the original sequence. The new sequence will contain all elements after the first num elements.

func Take

func Take[K, V any](seq iter.Seq2[K, V], num int) iter.Seq2[K, V]

Take returns a new sequence that contains the first num elements of the original sequence. The new sequence will contain only the first num elements.

Types

This section is empty.

Jump to

Keyboard shortcuts

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