Documentation
¶
Index ¶
- func Contains[S comparable](arr []S, v S) bool
- func Filter[S any](arr []S, f func(S) bool) []S
- func FrequencyList[T comparable](args []T) map[T]int
- func Map[S, R any](arr []S, f func(S) R) []R
- func Reduce[R, S any](arr []S, init R, f func(s S, r R) R) R
- func Reverse[S comparable](arr []S) []S
- func Sum[V summable](ns []V) V
- func Take[T any](arr []T, n int) []T
- func TrimSplit(s string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[S comparable](arr []S, v S) bool
Contains returns true if slice `arr` contains a value equal to `v`.
func Filter ¶
Map applies a function `f` to each element in a slice `arr`, returning a new slice containing only those elements of `arr` for which `f` evaluates to true.
func FrequencyList ¶
func FrequencyList[T comparable](args []T) map[T]int
FrequencyList accepts a slice of comparable-type values and returns a map[T]int representing how many times each key appears in the input slice.
func Map ¶
func Map[S, R any](arr []S, f func(S) R) []R
Map applies a function `f` to each element in a slice `arr`, returning a new slice of the results of `f`.
func Reduce ¶
func Reduce[R, S any](arr []S, init R, f func(s S, r R) R) R
Reduce iterates through a slice `arr`, accumulating the result of `f` to some initial value `init`, then returning the final result.
func Sum ¶
func Sum[V summable](ns []V) V
Sum is a convenience method to add up a slice of numbers (as defined by an internal type).
Types ¶
This section is empty.