Documentation ¶
Index ¶
- func All[S ~[]T, T any](items S, f func(item T) bool) bool
- func Any[S ~[]T, T any](items S, f func(item T) bool) bool
- func Count[S ~[]T, T comparable](items S, item T) int
- func CountBy[S ~[]T, T any](items S, f func(item T) bool) int
- func Filter[S ~[]T, T any](items S, f func(item T) bool) S
- func ForEach[S ~[]T, T any](items S, f func(item T))
- func Map[S ~[]T, T any, U any](items S, f func(item T) U) []U
- func Max[S ~[]T, T constraints.Ordered](items S) (T, error)
- func Min[S ~[]T, T constraints.Ordered](items S) (T, error)
- func Reduce[S ~[]T, T any, U any](items S, acc U, f func(item T, acc U) U) U
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
All returns true if the function 'f' evaluates to true for all elements in the slice 'items'.
func Any ¶
Any returns true if the function 'f' evaluates to true for any element of the slice 'items'
func Count ¶
func Count[S ~[]T, T comparable](items S, item T) int
Count returns the number of occurrences for an element in a slice.
func CountBy ¶
CountBy returns the number of elements in slice 'items' for which the function 'f' evaluates to true.
func Filter ¶
Filter returns a new slice with the elements from the 'items' slice for which the function 'f' returned true.
func ForEach ¶
func ForEach[S ~[]T, T any](items S, f func(item T))
ForEach calls the function 'f' for each element in the slice 'items'.
func Map ¶
Map calls the function 'f' for each element of the 'items' slice and returns a new slice with the results.
func Max ¶
func Max[S ~[]T, T constraints.Ordered](items S) (T, error)
Max returns the maximum element from the given slice.
func Min ¶
func Min[S ~[]T, T constraints.Ordered](items S) (T, error)
Min returns the minimum element from the given slice.
Types ¶
This section is empty.