Documentation ¶
Index ¶
- func Contains[T comparable](slice []T, e T) bool
- func CountWhere[T any](slice []T, condition func(T) bool) int
- func Diff[T comparable](original, changed []T) (newItems, removedItems []T)
- func Map[T any, K comparable, V any](slice []T, fn func(T) (K, V)) map[K]V
- func Transform[T any, V any](slice []T, fn func(T) V) []V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](slice []T, e T) bool
Contains returns true if a slice contains an element
func CountWhere ¶ added in v0.1.20
CountWhere returns the number of elements in a slice that satisfy a given condition.
func Diff ¶ added in v1.3.0
func Diff[T comparable](original, changed []T) (newItems, removedItems []T)
Diff finds the difference between two slices, `original` and `changed`. It returns two new slices for the changes. The first slice contains new items that are in `changed` but not in `original`, and the second slice contains removed items that are in `original` but not in `changed`.
func Map ¶ added in v0.1.2
func Map[T any, K comparable, V any](slice []T, fn func(T) (K, V)) map[K]V
Map takes a slice of a given type and a function to extract a map key and value from slice elements, returns a new map with those key-value pairs. Note that if multiple elements in the slice return the same key, the element that appears last in the slice will be the (only) element that maps to the key.
Types ¶
This section is empty.