Documentation ¶
Index ¶
- func AppendOrReplace[T any](slice []T, value T, fn func(T) bool) []T
- func Filter[T any](slice []T, fn func(T) bool) []T
- func Find[T any](slice []T, fn func(T) bool) (T, bool)
- func FindVariant[T any, U any](slice []U) (T, bool)
- func FlatMap[T, U any](slice []T, fn func(T) []U) []U
- func GroupBy[T any, K comparable](slice []T, fn func(T) K) map[K][]T
- func Map[T, U any](slice []T, fn func(T) U) []U
- func MapErr[T, U any](slice []T, fn func(T) (U, error)) ([]U, error)
- func Reduce[T, U any](slice []T, initial U, fn func(U, T) U) U
- func Sort[T cmp.Ordered](slice []T) []T
- func Unique[T comparable](slice []T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendOrReplace ¶
AppendOrReplace appends a value to a slice if the slice does not contain a value for which the given function returns true. If the slice does contain such a value, it is replaced.
func FindVariant ¶ added in v0.232.0
FindVariant finds the first element in a slice that can be cast to the given type.
func GroupBy ¶
func GroupBy[T any, K comparable](slice []T, fn func(T) K) map[K][]T
GroupBy groups the elements of a slice by the result of a function.
func Unique ¶ added in v0.272.0
func Unique[T comparable](slice []T) []T
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.