Documentation ¶
Index ¶
- func All[T any](source []T, predicate func(T) bool) bool
- func Any[T any](source []T, predicate func(T) bool) bool
- func Concat[T any](first []T, other ...[]T) []T
- func Distinct[T comparable](source []T) []T
- func Expand[T any](generator func(idx int) T, count int) []T
- func Expand2[T any](generator func() T, count int) []T
- func Filter[T any](source []T, predicate func(T) bool) []T
- func FlatMap[T, S any](source []T, f func(T) []S) []S
- func Flatten[T any](source [][]T) []T
- func ForEach[T any](source []T, f func(T))
- func GroupBy[T any, K comparable](source []T, fn func(T) K) map[K][]T
- func HasDuplicates[T comparable](source []T) bool
- func Last[T any](source []T) T
- func Map[T, S any](source []T, f func(T) S) []S
- func Reduce[T, S any](source []T, initial S, f func(current S, element T) S) S
- func Reverse[T1 any](source []T1) []T1
- func ToMap[T1 any, T2 comparable](source []T1, lookup func(T1) T2, strictUniqueness ...bool) map[T2]T1
- func TryCast[T1 any, T2 any](source []T1) []T2
- func While[T any](source []T, f func(T) bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Distinct ¶
func Distinct[T comparable](source []T) []T
Distinct returns a new slice where duplicate entries are removed
func FlatMap ¶
func FlatMap[T, S any](source []T, f func(T) []S) []S
FlatMap composes Map and Flatten
func Flatten ¶
func Flatten[T any](source [][]T) []T
Flatten flattens a slice of slices into a single slice
func ForEach ¶
func ForEach[T any](source []T, f func(T))
ForEach performs the given function on every element of the slice
func GroupBy ¶
func GroupBy[T any, K comparable](source []T, fn func(T) K) map[K][]T
GroupBy returns a map with given items each group into a slice
func HasDuplicates ¶
func HasDuplicates[T comparable](source []T) bool
HasDuplicates returns true if a slice has duplicate entries, false otherwise.
func Last ¶
func Last[T any](source []T) T
Last returns the last element of a slice, panics if the slice is empty
func Reduce ¶
func Reduce[T, S any](source []T, initial S, f func(current S, element T) S) S
Reduce performs a reduction to a single value of the source slice according to the given function
func Reverse ¶
func Reverse[T1 any](source []T1) []T1
Reverse returns a new slice in which the elements aree listed in reverse order
func ToMap ¶
func ToMap[T1 any, T2 comparable](source []T1, lookup func(T1) T2, strictUniqueness ...bool) map[T2]T1
ToMap returns a map from the given slice with keys associated by the lookup function. Panics if strictUniqueness is set, otherwise overrides values for colliding keys.
Types ¶
This section is empty.