seq

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package seq holds small, pure helpers over iterators and slices: mapping, filtering, flattening, grouping and de-duplicating without the caller holding any mutable state.

The bodies of these helpers hide the accumulation loops so that no caller needs one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Duplicates

func Duplicates[T any, K cmp.Ordered](items iter.Seq[T], key func(T) K) []K

Duplicates returns the keys that occur more than once, sorted.

func Filter

func Filter[T any](items iter.Seq[T], keep func(T) bool) []T

Filter returns the items for which keep is true.

func FlatMap

func FlatMap[T, R any](items iter.Seq[T], f func(T) []R) []R

FlatMap returns the concatenation of f applied to every item.

func FlatMapIndexed

func FlatMapIndexed[T, R any](items []T, f func(int, T) []R) []R

FlatMapIndexed is FlatMap over a slice, passing the index of each item.

func FlatMapPairs

func FlatMapPairs[K, V, R any](pairs iter.Seq2[K, V], f func(K, V) []R) []R

FlatMapPairs is FlatMap over the pairs of an iterator.

func FlatMapSlice

func FlatMapSlice[T, R any](items []T, f func(T) []R) []R

FlatMapSlice is FlatMap over a slice.

func GroupBy

func GroupBy[T any, K comparable](items iter.Seq[T], key func(T) K) map[K][]T

GroupBy returns the items grouped by key, each group in input order.

The items are stably sorted by a textual form of their key and then cut into runs of equal keys, so the grouping needs no mutable state.

func Map

func Map[T, R any](items iter.Seq[T], f func(T) R) []R

Map returns f applied to every item.

func Occurrences

func Occurrences[T any, K comparable](items []T, key func(T) K) map[K][]T

Occurrences returns, for every key, the items that carry it, in input order.

func Pairs

func Pairs[K comparable, V any](entries map[K]V, keep func(K, V) bool) iter.Seq2[K, V]

Pairs yields the entries of a map for which keep is true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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