Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply[T any](s []T, f func(T) T) []T
Apply a function to every element in a slice, returning the parameter slice, whose elements may be mutated.
func Map ¶
func Map[X, Y any](s []X, f func(X) Y) []Y
Map every element in an input slice to a countepart output element by applying the specified function.
func Sort ¶ added in v1.20.0
func Sort[T any](s []T, f Comparator[T])
Sort a slice in place by appying the specified comparator function to elements.
func Sorted ¶ added in v1.20.0
func Sorted[T any](s []T, f Comparator[T]) []T
Sort a copy of a slice by appying the specified comparator function to elements. The sorted copy is returned.
Types ¶
type Comparator ¶ added in v1.20.0
Comparator evalutes two arguments of the same type and returns an integer value describing how they compare, returning:
- 1 if a > b
- 0 if the elements are equal
- -1 if a < b
Click to show internal directories.
Click to hide internal directories.