Documentation
¶
Index ¶
- func Filter[T any](slice []T, condition func(T) bool) []T
- func Find[T any](slice []T, condition func(T) bool) *T
- func FindIndex[T any](slice []T, condition func(T) bool) int
- func ForEach[T any](slice []T, callback func(T))
- func Map[Input any, Output any](slice []Input, transform func(Input) Output) []Output
- func Reduce[T any, U any](slice []T, reducer func(U, T) U, initial U) U
- func Some[T any](slice []T, condition func(T) bool) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
Filter applies a condition function to each element of a slice and returns a new slice containing only the elements that satisfy the condition. If the input slice is nil, returns nil. If an element contains nil pointer fields, it is skipped. The original slice is not modified.
func Find ¶
Find searches for the first element in the provided slice that satisfies the given condition. If the input slice is nil, it returns nil.
func FindIndex ¶
FindIndex searches for the index of the first element in the provided slice that satisfies the given condition. If the input slice is nil, it returns -1.
func ForEach ¶
func ForEach[T any](slice []T, callback func(T))
ForEach executes a given callback function for each element in the provided slice. If the input slice is nil, the function does nothing.
func Map ¶
Map applies a given transformation function to each element of the provided slice and returns a new slice containing the results. If the input slice is nil, it returns nil.
Types ¶
This section is empty.