Documentation
¶
Index ¶
- func All[T any](items []T, ok func(T) bool) bool
- func AllEqual[T comparable](items []T, item T) bool
- func AllFalse(items []bool) bool
- func AllGreater[T cmp.Ordered](items []T, value T) bool
- func AllGreaterEqual[T cmp.Ordered](items []T, value T) bool
- func AllIndexFunc[T any](items []T, itemFn func(T) bool) []int
- func AllIndexOf[T comparable](items []T, item T) []int
- func AllIndexed[T any](items []T, ok func(int, T) bool) bool
- func AllLesser[T cmp.Ordered](items []T, value T) bool
- func AllLesserEqual[T cmp.Ordered](items []T, value T) bool
- func AllSame[T comparable](items []T) bool
- func AllSameFunc[T any, K comparable](items []T, keyFn func(T) K) bool
- func AllTrue(items []bool) bool
- func AllUnique[T comparable](items []T) bool
- func AllUniqueFunc[T any, K comparable](items []T, keyFn func(T) K) bool
- func Any[T any](items []T, ok func(T) bool) bool
- func AnyFalse(items []bool) bool
- func AnyIndexed[T any](items []T, ok func(int, T) bool) bool
- func AnyTrue(items []bool) bool
- func Apply[T any](items []T, task func(T) T) []T
- func ArgMax[T cmp.Ordered](items []T) int
- func ArgMin[T cmp.Ordered](items []T) int
- func Cap[T any](items []T) int
- func Copy[T any](items []T) []T
- func Count[T comparable](items []T, item T) int
- func CountFunc[T any](items []T, ok func(T) bool) int
- func CountUnique[T comparable](items []T) int
- func CountUniqueFunc[T any, K comparable](items []T, keyFn func(T) K) int
- func Deduplicate[T comparable](items []T) []T
- func DeduplicateFunc[T any, K comparable](items []T, keyFn func(T) K) []T
- func Filter[T any](items []T, keep func(T) bool) []T
- func FilterIndexed[T any](items []T, keep func(int, T) bool) []T
- func GetFuncOrDefault[T any](items []T, itemFn func(T) bool, defaultValue T) T
- func GetOrDefault[T comparable](items []T, item T, defaultValue T) T
- func GetRandom[T any](items []T) (T, bool)
- func GroupByFunc[T any, K comparable](items []T, keyFn func(T) K) map[K][]T
- func Has[T comparable](items []T, item T) bool
- func HasNo[T comparable](items []T, item T) bool
- func InclusiveRange[T number.Integer](first, last T) []T
- func IndexFunc[T any](items []T, itemFn func(T) bool) int
- func IndexLookup[T comparable](items []T) map[T]int
- func IndexOf[T comparable](items []T, item T) int
- func IsEmpty[T any](items []T) bool
- func Last[T any](items []T, rank int) (T, bool)
- func LastIndex[T any](items []T) int
- func Len[T any](items []T) int
- func Map[T, V any](items []T, convert func(T) V) []V
- func MapIf[T, V any](items []T, convert func(T) (V, bool)) []V
- func MapIndexed[T, V any](items []T, convert func(int, T) V) []V
- func MapIndexedIf[T, V any](items []T, convert func(int, T) (V, bool)) []V
- func MapList[T any](indexes []int, items []T) []T
- func MapLookup[K comparable, V any](keys []K, lookup map[K]V) []V
- func MustGetRandom[T any](items []T) T
- func MustLast[T any](items []T, rank int) T
- func NewEmpty[T any](capacity int) []T
- func NotAny[T any](items []T, ok func(T) bool) bool
- func NotAnyIndexed[T any](items []T, ok func(int, T) bool) bool
- func NotEmpty[T any](items []T) bool
- func Product[T number.Type](numbers []T) T
- func Range[T number.Integer](start, end T) []T
- func Reduce[T any](items []T, initial T, reducer func(T, T) T) T
- func Remove[T comparable](items []T, item T) ([]T, bool)
- func RemoveAll[T comparable](items []T, item T) []T
- func RemoveAllFunc[T any](items []T, itemFn func(T) bool) []T
- func RemoveFunc[T any](items []T, itemFn func(T) bool) ([]T, bool)
- func RepeatedItem[T any](value T, count int) []T
- func Shuffle[T any](items []T)
- func Sum[T number.Type](numbers []T) T
- func SumOf[T any, V number.Type](items []T, convert func(T) V) V
- func Tally[T comparable](items []T) map[T]int
- func TallyFunc[T any, K comparable](items []T, keyFn func(T) K) map[K]int
- func ToAny[T any](items []T) []any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllEqual ¶
func AllEqual[T comparable](items []T, item T) bool
AllEqual checks if all list items are equal to given value
func AllGreater ¶
AllGreater checks if all list items are greater than given value
func AllGreaterEqual ¶
AllGreaterEqual checks if all list items are greater or equal to given value
func AllIndexFunc ¶
AllIndexFunc returns all indexes of item in the list, using the item function
func AllIndexOf ¶
func AllIndexOf[T comparable](items []T, item T) []int
AllIndexOf gets all indexes of given item
func AllIndexed ¶
AllIndexed checks if all list item passes the ok function: (index, item)
func AllLesserEqual ¶
AllLesserEqual checks if all list items are lesser or equal to given value
func AllSameFunc ¶
func AllSameFunc[T any, K comparable](items []T, keyFn func(T) K) bool
AllSameFunc checks if all list key values are same
func AllUnique ¶
func AllUnique[T comparable](items []T) bool
AllUnique checks if all list items are unique
func AllUniqueFunc ¶
func AllUniqueFunc[T any, K comparable](items []T, keyFn func(T) K) bool
AllUniqueFunc checks if all list key values are unique
func AnyIndexed ¶
AnyIndexed checks if any list item passes the ok function: (index, item)
func Apply ¶
func Apply[T any](items []T, task func(T) T) []T
Apply applies the task function to each item
func Count ¶
func Count[T comparable](items []T, item T) int
Count counts the number of occurrence of item in the list
func CountUnique ¶
func CountUnique[T comparable](items []T) int
CountUnique counts the number of unique items in list
func CountUniqueFunc ¶
func CountUniqueFunc[T any, K comparable](items []T, keyFn func(T) K) int
CountUniqueFunc counts the number of unique key values in the list, using the key function
func Deduplicate ¶
func Deduplicate[T comparable](items []T) []T
Deduplicate removes duplicates from the list, preserving item order
func DeduplicateFunc ¶
func DeduplicateFunc[T any, K comparable](items []T, keyFn func(T) K) []T
DeduplicateFunc removes duplicate key values from the list, preserving item order, using the key function
func FilterIndexed ¶
FilterIndexed filters the list by only keeping items that pass the keep function: (index, item)
func GetFuncOrDefault ¶
GetFuncOrDefault returns the first item that passes the item function, or returns the default value
func GetOrDefault ¶
func GetOrDefault[T comparable](items []T, item T, defaultValue T) T
GetOrDefault returns the first item that matches given item, or returns default value
func GroupByFunc ¶
func GroupByFunc[T any, K comparable](items []T, keyFn func(T) K) map[K][]T
GroupByFunc groups the list items using the key function
func Has ¶
func Has[T comparable](items []T, item T) bool
Has checks if any list items are equal to given value
func HasNo ¶
func HasNo[T comparable](items []T, item T) bool
HasNo checks if no list items are equal to given value
func InclusiveRange ¶
InclusiveRange creates a new list, with numbers from [first, last]
func IndexFunc ¶
IndexFunc returns the index of item (or -1 if not in list), using the item function
func IndexLookup ¶
func IndexLookup[T comparable](items []T) map[T]int
IndexLookup creates a lookup of { item : index } from list. This loses data if list items are not unique
func IndexOf ¶
func IndexOf[T comparable](items []T, item T) int
IndexOf gets the index of given item, returns -1 if not in list
func Last ¶
Last returns the nth item from the back of the list (starts at 1), and a flag which indicates if it is valid
func Map ¶
func Map[T, V any](items []T, convert func(T) V) []V
Map applies the convert function for each list item
func MapIf ¶
MapIf combines Map and Filter: apply the convert function, and filter items based on result flag
func MapIndexed ¶
MapIndexed applies the convert function for each indexed item
func MapIndexedIf ¶
MapIndexedIf combines Map and Filter: apply the convert function (index, item), and filter items based on result flag
func MapLookup ¶
func MapLookup[K comparable, V any](keys []K, lookup map[K]V) []V
MapLookup maps the keys to given lookup map. Can have zero values for invalid keys
func MustGetRandom ¶
func MustGetRandom[T any](items []T) T
MustGetRandom gets a random item from List, and panics if list is empty
func MustLast ¶
MustLast returns the nth item from the back of the list (starts at 1). Panics if rank is not 1 <= rank <= N, where N = length of List.
func NotAnyIndexed ¶
NotAnyIndexed checks if no list item passes the ok function: (index, item)
func Reduce ¶
func Reduce[T any](items []T, initial T, reducer func(T, T) T) T
Reduce applies the reducer to each item to get the final result. The reducer function has the signature (result, item) => result
func Remove ¶
func Remove[T comparable](items []T, item T) ([]T, bool)
Remove removes the first item from list that matches given item
func RemoveAll ¶
func RemoveAll[T comparable](items []T, item T) []T
RemoveAll removes all items from list that matches given item
func RemoveAllFunc ¶
RemoveAllFunc removes all items from list that passes the item function
func RemoveFunc ¶
RemoveFunc removes the first item from list that passes the item function
func RepeatedItem ¶
RepeatedItem creates a new list, with <value> repeated <count> times
func Tally ¶
func Tally[T comparable](items []T) map[T]int
Tally computes the number of occurrence of each item in list
func TallyFunc ¶
func TallyFunc[T any, K comparable](items []T, keyFn func(T) K) map[K]int
TallyFunc computes the number of occurrence of each key value in the list, using the key function
Types ¶
This section is empty.