Documentation
¶
Overview ¶
Putting the FUN in FUNctions!
Index ¶
- func Each[T any](list []T, apply func(x T))
- func Filter[T any](list []T, filter func(v T) bool) []T
- func FirstOrElse[T any](list []T, other T) T
- func Map[T any, Y any](list []T, apply func(i int, x T) Y) []Y
- func Reduce[T any, V any](list []T, initial V, reducer func(v T, accumulator V) V) V
- func ReduceI[T any, V any](list []T, initial V, reducer func(i int, v T, accumulator V) V) V
- func ToMap[K comparable, V any](list []V, fn func(idx int, v V) (K, V)) map[K]V
- func Values[K comparable, T any](m map[K]T) []T
- type Tuple
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
returns a new list that is a subset of the previous list with elements that evaluate true for the given filter function.
func FirstOrElse ¶
func FirstOrElse[T any](list []T, other T) T
Retrieve the first element from the list or the provided `other`
func Reduce ¶
Reduce takes a list(slice) and produces a single value. The [initial] parameter will be what is passed to to the first iteration of the [reducer] fun.
func ToMap ¶
func ToMap[K comparable, V any](list []V, fn func(idx int, v V) (K, V)) map[K]V
convert a slice to a map, the provided function will return the key and value to populate the map with
func Values ¶
func Values[K comparable, T any](m map[K]T) []T
Types ¶
Click to show internal directories.
Click to hide internal directories.