Documentation
¶
Index ¶
- func All[T any](s []T, predicate func(T) bool) bool
- func Any[T any](s []T, predicate func(T) bool) bool
- func Contains[T comparable](s []T, v T) bool
- func Filter[T any](s []T, keep func(T) bool) []T
- func Find[T any](s []T, predicate func(T) bool) (T, bool)
- func Map[T, U any](s []T, f func(T) U) []U
- func Partition[T any](s []T, predicate func(T) bool) ([]T, []T)
- func Reduce[T, U any](s []T, initial U, reduce func(U, T) U) U
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](s []T, v T) bool
Contains checks if a slice contains a value. Uses == for comparison, so T must be comparable.
func Filter ¶
Filter returns a new slice containing only elements that satisfy the predicate. Returns nil if the input slice is nil.
func Find ¶
Find returns the first element that satisfies the predicate. Returns the zero value of T and false if no element is found.
func Map ¶
func Map[T, U any](s []T, f func(T) U) []U
Map transforms a slice using a mapping function. Returns nil if the input slice is nil.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.