Documentation
¶
Index ¶
- func FlatMap[E any, T any](from []E, fn func(fromEntry E) []T) []T
- func Map[E any, T any](from []E, fn func(fromEntry E) T) []T
- func MapWithErr[E any, T any](from []E, fn func(fromEntry E) (T, error)) ([]T, error)
- func MergeMaps[K comparable, V any](m1 map[K]V, m2 map[K]V) map[K]V
- func Reduce[E any, T any](from []E, initial T, fn func(accumulator T, current E) T) T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlatMap ¶
FlatMap can be used to convert any list from MemberType E to T. It takes a list of E (E can also be a *E) and a function that is used for each element of E to []T. Instead of returning [][]T, the resulting list gets flattened to []T. Mapping: [[-][-][-]] [[-][-][-]] -> [+][+][+][+][+][+]
func Map ¶
Map can be used to convert any list from MemberType E to T. It takes a list of E (E can also be a *E) and a function that is used for each element of E to T. It returns a []T after all.
Mapping: [-][-][-] -> [+][+][+]
func MapWithErr ¶
MapWithErr behaves like PointerMap, but stops mapping when fn returns an error. The first error that occurs is returned.
func MergeMaps ¶
func MergeMaps[K comparable, V any](m1 map[K]V, m2 map[K]V) map[K]V
MergeMaps merges two maps of same key and value types together. The second map m2 takes precedence in case of overlapping keys.
Types ¶
This section is empty.