iters

package
v0.0.0-...-c847dd0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: MIT Imports: 1 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[T any](seq iter.Seq[T], predicate func(T) bool) iter.Seq[T]

Filter returns a new sequence based on seq consisting only of those items where predicate returns true.

func Filter2

func Filter2[K comparable, V any](seq iter.Seq2[K, V], predicate func(K, V) bool) iter.Seq2[K, V]

Filter2 returns a new sequence based on seq consisting only of those pairs of items where predicate returns true.

func MapTransform

func MapTransform[K comparable, V, T any](src iter.Seq2[K, V], f func(K, V) T) iter.Seq[T]

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

func SliceSelectFirst[T any](items iter.Seq[T], predicate func(T) bool) (T, bool)

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

func SliceTransform[T, U any](src iter.Seq[T], f func(T) U) iter.Seq[U]

SliceTransform applies a function f to each item in a source sequence and returns a sequence of the results.

func SliceTransform2

func SliceTransform2[T any, K comparable, V any](src iter.Seq[T], f func(T) (K, V)) iter.Seq2[K, V]

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.

Jump to

Keyboard shortcuts

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