Documentation
¶
Index ¶
- func Any[T any](input []T, f func(T) bool) bool
- func Chunk[T any](w []T, size int) [][]T
- func Contains[T comparable](a []T, x T) bool
- func DistinctBy[T any, K comparable](w []T, key func(T) K) []T
- func Equals[T comparable](a, b []T) bool
- func Every[T any](a []T, f func(T) bool) bool
- func Fill[T any](a []T, start, end int, x T) []T
- func Filter[T any](a []T, f func(T) bool) []T
- func Filter0Loc[T any](a []T, f func(T) bool) []T
- func Find[T any](a []T, f func(T) bool) T
- func FlatMap[T, U any](a []T, f func(T) []U) []U
- func ForEach[T any](a []T, f func(T))
- func GroupBy[T any, K comparable](w []T, key func(T) K) map[K][]T
- func GroupCountBy[T any, K comparable](w []T, key func(T) K) map[K]int
- func GroupReduceBy[T any, K comparable, A any](w []T, key func(T) K, reduce func(A, T) A) map[K]A
- func GroupStatsBy[T any, K comparable, V Number](w []T, key func(T) K, value func(T) V) map[K]GroupStats[V]
- func GroupSumBy[T any, K comparable, V Number](w []T, key func(T) K, value func(T) V) map[K]V
- func GroupSumByWhere[T any, K comparable, V Number](w []T, where func(T) bool, key func(T) K, value func(T) V) map[K]V
- func IndexBy[T any, K comparable](w []T, key func(T) K) map[K]T
- func IndexOf[T comparable](a []T, x T) int
- func Join[T any](a []T, sep string) string
- func Map[T, U any](a []T, f func(T) U) []U
- func Map0Loc[T any](a []T, f func(T) T)
- func Max[T Number](a []T) T
- func Min[T Number](a []T) T
- func Partition[T any](w []T, f func(T) bool) ([]T, []T)
- func Pop[T any](a []T) (T, []T)
- func Product[T Number](a []T) T
- func Push[T any](a []T, x ...T) []T
- func Reduce[T any](a []T, f func(T, T) T) T
- func Reverse[T any](a []T) []T
- func Shift[T any](a []T) (T, []T)
- func Shuffle[T any](a []T) []T
- func Skip[T any](w []T, n int) []T
- func Some[T any](a []T, f func(T) bool) bool
- func Sort[T any](a []T, less func(i, j int) bool) []T
- func SortBy[T any, K cmp.Ordered](w []T, key func(T) K) []T
- func Sum[T Number](a []T) T
- func Take[T any](w []T, n int) []T
- func Union[T any](a, b []T) []T
- func Unique[T comparable](a []T) []T
- func Unshift[T any](a []T, x ...T) []T
- type Array
- func (a Array[T]) Any(f func(T) bool) bool
- func (a Array[T]) Chunk(size int) []Array[T]
- func (a Array[T]) DistinctBy(key func(T) string) Array[T]
- func (a Array[T]) Every(f func(T) bool) bool
- func (a Array[T]) Filter(f func(T) bool) Array[T]
- func (a Array[T]) Find(f func(T) bool) T
- func (a Array[T]) FlatMap(f func(T) []T) Array[T]
- func (a Array[T]) GroupBy(f func(T) string) map[string][]T
- func (a Array[T]) GroupCountBy(key func(T) string) map[string]int
- func (a Array[T]) GroupStatsBy(key func(T) string, value func(T) float64) map[string]GroupStats[float64]
- func (a Array[T]) GroupSumBy(key func(T) string, value func(T) float64) map[string]float64
- func (a Array[T]) GroupSumByWhere(where func(T) bool, key func(T) string, value func(T) float64) map[string]float64
- func (a Array[T]) IndexBy(key func(T) string) map[string]T
- func (a Array[T]) Length() int
- func (a Array[T]) Map(f func(T) T) Array[T]
- func (a Array[T]) Partition(f func(T) bool) (Array[T], Array[T])
- func (a Array[T]) Reduce(f func(T, T) T) T
- func (a Array[T]) Reverse() Array[T]
- func (a Array[T]) Shuffle() Array[T]
- func (a Array[T]) Skip(n int) Array[T]
- func (a Array[T]) Some(f func(T) bool) bool
- func (a Array[T]) Sort(f func(i, j int) bool) Array[T]
- func (a Array[T]) SortByFloat64(key func(T) float64) Array[T]
- func (a Array[T]) SortByString(key func(T) string) Array[T]
- func (a Array[T]) Take(n int) Array[T]
- type GroupStats
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](a []T, x T) bool
Contains
* Example: * a := []int{1, 2, 3, 4, 5} * b := Contains(a, 3) * fmt.Println(b) // true
func DistinctBy ¶ added in v1.0.3
func DistinctBy[T any, K comparable](w []T, key func(T) K) []T
func Equals ¶
func Equals[T comparable](a, b []T) bool
func Every ¶
Every
* Example: * a := []int{1, 2, 3, 4, 5} * b := Every(a, func(x int) bool { return x%2 == 0 }) * fmt.Println(b) // false
func Filter0Loc ¶ added in v1.0.0
with side effects
func ForEach ¶
func ForEach[T any](a []T, f func(T))
ForEach
* Example: * a := []int{1, 2, 3, 4, 5} * ForEach(a, func(x int) { fmt.Println(x) })
func GroupBy ¶ added in v0.0.2
func GroupBy[T any, K comparable](w []T, key func(T) K) map[K][]T
func GroupCountBy ¶ added in v1.0.3
func GroupCountBy[T any, K comparable](w []T, key func(T) K) map[K]int
func GroupReduceBy ¶ added in v1.0.3
func GroupReduceBy[T any, K comparable, A any](w []T, key func(T) K, reduce func(A, T) A) map[K]A
func GroupStatsBy ¶ added in v1.0.3
func GroupStatsBy[T any, K comparable, V Number](w []T, key func(T) K, value func(T) V) map[K]GroupStats[V]
func GroupSumBy ¶ added in v1.0.3
func GroupSumBy[T any, K comparable, V Number](w []T, key func(T) K, value func(T) V) map[K]V
GroupSumBy groups rows by key and sums a numeric value for each group.
* Example: * totalByName := GroupSumBy(items, * func(item Item) string { return item.Name }, * func(item Item) float64 { return item.Price }, * )
func GroupSumByWhere ¶ added in v1.0.3
func GroupSumByWhere[T any, K comparable, V Number](w []T, where func(T) bool, key func(T) K, value func(T) V) map[K]V
func IndexBy ¶ added in v1.0.3
func IndexBy[T any, K comparable](w []T, key func(T) K) map[K]T
func IndexOf ¶
func IndexOf[T comparable](a []T, x T) int
IndexOf
* Example: * a := []int{1, 2, 3, 4, 5} * b := IndexOf(a, 3) * fmt.Println(b) // 2
func Min ¶
func Min[T Number](a []T) T
Min array of numbers
* Example: * a := []int{1, 2, 3, 4, 5} * b := Min(a) * fmt.Println(b) // 1
func Pop ¶
func Pop[T any](a []T) (T, []T)
Pop removes and returns the last element of the slice
* Example: * a := []int{1, 2, 3, 4, 5} * b, c := Pop(a) * fmt.Println(b, c) // 5 [1 2 3 4]
func Product ¶
func Product[T Number](a []T) T
Product array of numbers
* Example: * a := []int{1, 2, 3, 4, 5} * b := Product(a) * fmt.Println(b) // 120
func Reverse ¶
func Reverse[T any](a []T) []T
Reverse
* Example: * a := []int{1, 2, 3, 4, 5} * b := Reverse(a) * fmt.Println(b) // [5 4 3 2 1]
func Shuffle ¶
func Shuffle[T any](a []T) []T
Shuffle
* Example: * a := []int{1, 2, 3, 4, 5} * b := Shuffle(a) * fmt.Println(b) // [2 5 4 3 1]
func Unique ¶
func Unique[T comparable](a []T) []T
Types ¶
type Array ¶
type Array[T any] []T