collect

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: GPL-3.0 Imports: 1 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[I ~[]T, T any](input I, condition func(t T) bool) (output []T)

All collects all items from input that satisfy the condition Empty or nil input returns nil output

func CopyMapper added in v0.27.0

func CopyMapper[T any](input T) T

CopyMapper returns a copy of the input

func First

func First[I ~[]T, T any](input I, condition func(t T) bool) *T

First collects the first item from input that satisfies the condition Empty or nil input returns nil output

func From

func From[I ~[]T, T, R any](input I, mapper func(t T) R) (output []R)

From translates a slice into another using a mapper func (T) => (R). Empty or nil input returns nil output

func FromMap

func FromMap[M ~map[K1]V1, K1, K2 comparable, V1, V2 any](input M, mapper func(K1, V1) (K2, V2, bool)) (output map[K2]V2)

FromMap translates a map into another using a mapper func (k1, v2) => (k2, v2, include). Empty or nil input returns nil output

func In

func In[E comparable](values ...E) (condition func(item E) bool)

In returns a new condition that is true as one of the values matches

func KVMapper added in v0.27.0

func KVMapper[K1, K2 comparable, V1, V2 any](kMapper func(K1) K2, vMapper func(V1) V2) func(K1, V1) (K2, V2, bool)

KVMapper returns a mapper for FromMap that delegates to a separate key and value mapper func

func Last

func Last[I ~[]T, T any](input I, condition func(t T) bool) *T

Last collects the last item from input that satisfies the condition Empty or nil input returns nil output

func Not

func Not[T any, C func(t T) bool](condition C) C

Not inverts the meaning of condition

func With

func With[C ~func(t T) bool, T any](conditions ...C) (condition C)

With returns a new condition that is true when all conditions match

Types

This section is empty.

Jump to

Keyboard shortcuts

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