Documentation
¶
Index ¶
- func All[T any](arr []T, fn func(T) bool) bool
- func Any[T any](arr []T, fn func(T) bool) bool
- func Contains[T comparable](arr []T, pivot T) bool
- func Count[T any](arr []T, fn func(T) bool) int
- func Filter[T any](arr []T, fn func(T) bool) []T
- func Find[T any](arr []T, fn func(T) bool) *T
- func FindInt(slice []int, target int) bool
- func FindString(slice []string, target string) bool
- func FindUint(slice []uint, target uint) bool
- func Flatten[T any](arr [][]T) []T
- func GroupBy[T any, V comparable](arr []T, fn func(T) V) map[V][]T
- func HasString(slice []string, str string) bool
- func Index[T any](arr []T, fn func(T) bool) int
- func IterToArray[U any, V any, T Iterable[U, V]](iter T) []V
- func Map[T any, V any](arr []T, fn func(T) V) []V
- func Reduce[T any, V any](arr []T, reduce func(V, T) V, v V) V
- func RemoveString(slice []string, remove func(item string) bool) []string
- func Sort[T any](arr []T, cmp func(T, T) bool)
- type Iterable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](arr []T, pivot T) bool
Contains test if target array contains pivot If T is a pointer, T needs to implement Equal(T) function, otherwise the pointer address If T is not a pointer, T could be either
func FindString ¶
FindString return true if target in slice, return false if not.
func GroupBy ¶
func GroupBy[T any, V comparable](arr []T, fn func(T) V) map[V][]T
GroupBy group by array items with given projection function
func IterToArray ¶
IterToArray convert iterable to list. Next() should be called to get the first item
func RemoveString ¶
RemoveString remove string from slice if function return true.
Types ¶
Click to show internal directories.
Click to hide internal directories.