Documentation ¶
Index ¶
- func Any[T any](arr []T, fn func(elem T) bool) T
- func Concat[T comparable](arr []T, delimiter string) string
- func Count[T any](arr []T) int
- func If[T any](cond bool, trueValue, falseValue T) T
- func IsAll[T any](arr []T, fn func(elem T) bool) bool
- func IsAny[T any](arr []T, fn func(elem T) bool) bool
- func IsEmpty[T any](arr []T) bool
- func IsNone[T any](arr []T, fn func(elem T) bool) bool
- func Map[T any, V any](arr []T, fn func(elem T) V) []V
- func Reverse[T any](arr []T) []T
- func Select[T any](arr []T, fn func(elem T) bool) []T
- func Sum[T any, V constraints.Integer | constraints.Float](initialValue V, arr []T, fn func(elem T) V) V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Any ¶
Any checks arr whether any of the elements satistifed the fn criteria AND then return the first found element. If no fn criteria given, return default value as the function assume that it can't check the criteria.
func Concat ¶
func Concat[T comparable](arr []T, delimiter string) string
Concat creates string containing arr elements with delimiter. E.g: Concat([]int{1, 2, 3}, ",") => "1,2,3"
func IsAll ¶
IsAll checks arr whether all of the elements satisfied the fn criteria If no fn criteria given, return false as the function assume that it can't check the criteria.
func IsAny ¶
IsAny checks arr whether any of the elements satisfied the fn criteria True if at least 1 element satisfied If no fn criteria given, return false as the function assume that it can't check the criteria.
func IsNone ¶
IsNone checks arr whether none of the elements satisfied the fn criteria. True if none satisfied. If no fn criteria given, return default value as the function assume that it can't check the criteria.
func Map ¶
Map maps new value(s) from arr, you can provide your own map function via fn. E.g: Map(int{1, 2, 3}, func(i int) string { strconv.Itoa(i) }) to produce new array of string
func Select ¶
Select filters elements that satisfied the fn criteria If no fn criteria given, return the original arr
func Sum ¶
func Sum[T any, V constraints.Integer | constraints.Float](initialValue V, arr []T, fn func(elem T) V) V
Sum sums value from evaluation fn function you can provide initialValue of the sum if no fn criteria given, return default value of V
Types ¶
This section is empty.