Documentation
¶
Index ¶
- func Every[T comparable](slice []T, predicate func(value T, index int, slice []T) bool) bool
- func Filter[T comparable](slice []T, predicate func(value T, index int, slice []T) bool) []T
- func Find[T comparable](slice []T, predicate func(value T, index int, slice []T) bool) T
- func FindIndex[T comparable](slice []T, predicate func(value T, index int, slice []T) bool) int
- func FindLast[T comparable](slice []T, predicate func(value T, index int, slice []T) bool) T
- func FindLastIndex[T comparable](slice []T, predicate func(value T, index int, slice []T) bool) int
- func Flat[T comparable](slice [][]T) []T
- func ForEach[T comparable](slice []T, predicate func(value T, index int, slice []T))
- func Includes[T comparable](slice []T, element T, fromIndex int) bool
- func IndexOf[T comparable](slice []T, element T, fromIndex int) int
- func LastIndexOf[T comparable](slice []T, element T, fromIndex int) int
- func Map[T comparable](slice []T, predicate func(value T, index int, slice []T) T) []T
- func Pop[T comparable](slice []T) T
- func Push[T comparable](slice []T, elements ...T) []T
- func Reduce[T comparable, R comparable](slice []T, predicate func(accumulator R, value T, index int, slice []T) R, ...) R
- func Remove[T comparable](slice []T, element T) []T
- func Shift[T comparable](slice []T) T
- func Some[T comparable](slice []T, predicate func(value T, index int, slice []T) bool) bool
- func Splice[T comparable](slice []T, start, deleteCount int, elements ...T) []T
- func Unshift[T comparable](slice []T, elements ...T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Every ¶
func Every[T comparable]( slice []T, predicate func(value T, index int, slice []T) bool, ) bool
Every returns true if all elements satisfy predicate.
- If at least one element does not satisfy predicate, false is returned.
func Filter ¶
func Filter[T comparable]( slice []T, predicate func(value T, index int, slice []T) bool, ) []T
Filter returns slice with elements that satisfy predicate.
- If slice is empty, slice is returned.
func Find ¶
func Find[T comparable]( slice []T, predicate func(value T, index int, slice []T) bool, ) T
Find returns first element that satisfies predicate.
- If element is not found, zero-value is returned.
func FindIndex ¶
func FindIndex[T comparable]( slice []T, predicate func(value T, index int, slice []T) bool, ) int
FindIndex returns first index of element that satisfies predicate.
- If index is not found, -1 is returned.
func FindLast ¶
func FindLast[T comparable]( slice []T, predicate func(value T, index int, slice []T) bool, ) T
FindLast returns last element that satisfies predicate.
- If element is not found, zero-value is returned.
func FindLastIndex ¶
func FindLastIndex[T comparable]( slice []T, predicate func(value T, index int, slice []T) bool, ) int
FindLastIndex returns last index of element that satisfies predicate.
- If index is not found, -1 is returned.
func Flat ¶
func Flat[T comparable](slice [][]T) []T
Flat returns slice with sub-slices concatenated.
- If slice is empty, slice is returned.
func ForEach ¶
func ForEach[T comparable]( slice []T, predicate func(value T, index int, slice []T), )
ForEach executes predicate on every element in slice.
- If slice is empty, predicate is not executed.
func Includes ¶
func Includes[T comparable](slice []T, element T, fromIndex int) bool
Includes returns true if element is found in slice.
- If fromIndex is negative, it is set to 0.
- If fromIndex is greater than slice length, false is returned.
- If element is not found, false is returned.
func IndexOf ¶
func IndexOf[T comparable](slice []T, element T, fromIndex int) int
IndexOf returns first index of element in slice.
- If fromIndex is negative, it is set to 0.
- If fromIndex is greater than slice length, -1 is returned.
- If element is not found, -1 is returned.
func LastIndexOf ¶
func LastIndexOf[T comparable](slice []T, element T, fromIndex int) int
LastIndexOf returns last index of element in slice.
- If fromIndex is negative, it is set to 0.
- If fromIndex is greater than slice length, -1 is returned.
- If element is not found, -1 is returned.
func Map ¶
func Map[T comparable]( slice []T, predicate func(value T, index int, slice []T) T, ) []T
Map returns slice with elements after applying predicate.
- If slice is empty, slice is returned.
func Pop ¶
func Pop[T comparable](slice []T) T
Pop returns last element of slice.
- If slice is empty, zero-value is returned.
func Push ¶
func Push[T comparable](slice []T, elements ...T) []T
Push returns slice with elements added at end.
- If elements is empty, slice is returned.
func Reduce ¶
func Reduce[T comparable, R comparable]( slice []T, predicate func(accumulator R, value T, index int, slice []T) R, initial R, ) R
Reduce returns accumulator after applying predicate to each element.
- If slice is empty, initial is returned.
func Remove ¶
func Remove[T comparable](slice []T, element T) []T
Remove returns slice without element.
- If element is not found, slice is returned.
func Shift ¶
func Shift[T comparable](slice []T) T
Shift returns first element of slice.
- If slice is empty, zero-value is returned.
func Some ¶
func Some[T comparable]( slice []T, predicate func(value T, index int, slice []T) bool, ) bool
Some returns true if at least one element satisfies predicate.
- If no element satisfies predicate, false is returned.
func Splice ¶
func Splice[T comparable](slice []T, start, deleteCount int, elements ...T) []T
Splice returns slice with elements added at start.
- If start is negative or greater than slice length, it is set to slice length.
- If deleteCount is negative, it is set to 0.
- If deleteCount is greater than slice length minus start, it is set to slice length minus start.
func Unshift ¶
func Unshift[T comparable](slice []T, elements ...T) []T
Unshift returns slice with elements added at start.
- If elements is empty, slice is returned.
Types ¶
This section is empty.