Documentation ΒΆ
Index ΒΆ
- func Assign[K comparable, V any](maps ...map[K]V) map[K]V
- func Attempt(maxIteration int, f func(int) error) (int, error)
- func Chunk[T any](collection []T, size int) [][]T
- func Contains[T comparable](collection []T, element T) bool
- func Difference[T comparable](list1 []T, list2 []T) ([]T, []T)
- func Empty[T any]() T
- func Every[T comparable](collection []T, subset []T) bool
- func Fill[T Clonable[T]](collection []T, initial T) []T
- func Filter[V any](collection []V, predicate func(V, int) bool) []V
- func Find[T any](collection []T, predicate func(T) bool) (T, bool)
- func FlatMap[T any, R any](collection []T, iteratee func(T, int) []R) []R
- func Flatten[T any](collection [][]T) []T
- func ForEach[T any](collection []T, iteratee func(T, int))
- func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V
- func GroupBy[T any, U comparable](collection []T, iteratee func(T) U) map[U][]T
- func If[T any](condition bool, result T) *ifElse[T]
- func IndexOf[T comparable](collection []T, element T) int
- func Intersect[T comparable](list1 []T, list2 []T) []T
- func Keys[K comparable, V any](in map[K]V) []K
- func Last[T any](collection []T) (T, error)
- func LastIndexOf[T comparable](collection []T, element T) int
- func Map[T any, R any](collection []T, iteratee func(T, int) R) []R
- func MapValues[K comparable, V any, R any](in map[K]V, iteratee func(V, K) R) map[K]R
- func Max[T constraints.Ordered](collection []T) T
- func Min[T constraints.Ordered](collection []T) T
- func Nth[T any](collection []T, nth int) (T, error)
- func PartitionBy[T any, K comparable](collection []T, iteratee func(x T) K) [][]T
- func Reduce[T any, R any](collection []T, accumulator func(R, T, int) R, initial R) R
- func Repeat[T Clonable[T]](count int, initial T) []T
- func Reverse[T any](collection []T) []T
- func Sample[T any](collection []T) T
- func Samples[T any](collection []T, count int) []T
- func Shuffle[T any](collection []T) []T
- func Some[T comparable](collection []T, subset []T) bool
- func Switch[T comparable, R any](predicate T) *switchCase[T, R]
- func Ternary[T any](condition bool, ifOutput T, elseOutput T) T
- func Times[T any](count int, iteratee func(int) T) []T
- func ToMap[K comparable, V any](collection []V, iteratee func(V) K) map[K]V
- func ToPtr[T any](x T) *T
- func ToSlicePtr[T any](collection []T) []*T
- func Uniq[T comparable](collection []T) []T
- func UniqBy[T any, U comparable](collection []T, iteratee func(T) U) []T
- func Unzip2[A any, B any](tuples []Tuple2[A, B]) ([]A, []B)
- func Unzip3[A any, B any, C any](tuples []Tuple3[A, B, C]) ([]A, []B, []C)
- func Unzip4[A any, B any, C any, D any](tuples []Tuple4[A, B, C, D]) ([]A, []B, []C, []D)
- func Unzip5[A any, B any, C any, D any, E any](tuples []Tuple5[A, B, C, D, E]) ([]A, []B, []C, []D, []E)
- func Unzip6[A any, B any, C any, D any, E any, F any](tuples []Tuple6[A, B, C, D, E, F]) ([]A, []B, []C, []D, []E, []F)
- func Unzip7[A any, B any, C any, D any, E any, F any, G any](tuples []Tuple7[A, B, C, D, E, F, G]) ([]A, []B, []C, []D, []E, []F, []G)
- func Unzip8[A any, B any, C any, D any, E any, F any, G any, H any](tuples []Tuple8[A, B, C, D, E, F, G, H]) ([]A, []B, []C, []D, []E, []F, []G, []H)
- func Unzip9[A any, B any, C any, D any, E any, F any, G any, H any, I any](tuples []Tuple9[A, B, C, D, E, F, G, H, I]) ([]A, []B, []C, []D, []E, []F, []G, []H, []I)
- func Values[K comparable, V any](in map[K]V) []V
- type Clonable
- type Entry
- type Tuple2
- type Tuple3
- type Tuple4
- type Tuple5
- type Tuple6
- type Tuple7
- type Tuple8
- type Tuple9
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
func Assign ΒΆ
func Assign[K comparable, V any](maps ...map[K]V) map[K]V
Assign merges multiple maps from left to right.
func Attempt ΒΆ
Attempt invokes a function N times until it returns valid output. Returning either the caught error or nil. When first argument is less than `1`, the function runs until a sucessfull response is returned.
func Chunk ΒΆ
Chunk returns an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.
func Contains ΒΆ
func Contains[T comparable](collection []T, element T) bool
Contains returns true if an element is present in a collection.
func Difference ΒΆ
func Difference[T comparable](list1 []T, list2 []T) ([]T, []T)
Difference returns the difference between two collections. The first value is the collection of element absent of list2. The second value is the collection of element absent of list1.
func Every ΒΆ
func Every[T comparable](collection []T, subset []T) bool
Every returns true if all elements of a subset are contained into a collection.
func Fill ΒΆ
func Fill[T Clonable[T]](collection []T, initial T) []T
Fill fills elements of array with `initial` value.
func Filter ΒΆ
Filter iterates over elements of collection, returning an array of all elements predicate returns truthy for.
func Find ΒΆ
Find search an element in a slice based on a predicate. It returns element and true if element was found.
func FlatMap ΒΆ
FlatMap manipulates a slice and transforms and flattens it to a slice of another type.
func Flatten ΒΆ
func Flatten[T any](collection [][]T) []T
Flattens returns an array a single level deep.
func FromEntries ΒΆ
func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V
FromEntries transforms an array of key/value pairs into a map.
func GroupBy ΒΆ
func GroupBy[T any, U comparable](collection []T, iteratee func(T) U) map[U][]T
GroupBy returns an object composed of keys generated from the results of running each element of collection through iteratee.
func IndexOf ΒΆ
func IndexOf[T comparable](collection []T, element T) int
IndexOf returns the index at which the first occurrence of a value is found in an array or return -1 if the value cannot be found.
func Intersect ΒΆ
func Intersect[T comparable](list1 []T, list2 []T) []T
Intersect returns the intersection between two collections.
func LastIndexOf ΒΆ
func LastIndexOf[T comparable](collection []T, element T) int
IndexOf returns the index at which the last occurrence of a value is found in an array or return -1 if the value cannot be found.
func MapValues ΒΆ
func MapValues[K comparable, V any, R any](in map[K]V, iteratee func(V, K) R) map[K]R
MapValues manipulates a map values and transforms it to a map of another type.
func Max ΒΆ
func Max[T constraints.Ordered](collection []T) T
Max search the maximum value of a collection.
func Min ΒΆ
func Min[T constraints.Ordered](collection []T) T
Min search the minimum value of a collection.
func Nth ΒΆ
Nth returns the element at index `nth` of collection. If `nth` is negative, the nth element from the end is returned. An error is returned when nth is out of slice bounds.
func PartitionBy ΒΆ
func PartitionBy[T any, K comparable](collection []T, iteratee func(x T) K) [][]T
PartitionBy returns an array of elements split into groups. The order of grouped values is determined by the order they occur in collection. The grouping is generated from the results of running each element of collection through iteratee.
func Reduce ΒΆ
Reduce reduces collection to a value which is the accumulated result of running each element in collection through accumulator, where each successive invocation is supplied the return value of the previous.
func Reverse ΒΆ
func Reverse[T any](collection []T) []T
Reverse reverses array so that the first element becomes the last, the second element becomes the second to last, and so on.
func Shuffle ΒΆ
func Shuffle[T any](collection []T) []T
Shuffle returns an array of shuffled values. Uses the Fisher-Yates shuffle algorithm.
func Some ΒΆ
func Some[T comparable](collection []T, subset []T) bool
Some returns true if at least 1 element of a subset is contained into a collection.
func Switch ΒΆ
func Switch[T comparable, R any](predicate T) *switchCase[T, R]
Switch is a pure functional switch/case/default statement.
func Times ΒΆ
Times invokes the iteratee n times, returning an array of the results of each invocation. The iteratee is invoked with index as argument.
func ToMap ΒΆ
func ToMap[K comparable, V any](collection []V, iteratee func(V) K) map[K]V
ToMap transforms a slice or an array of structs to a map based on a pivot callback.
func ToSlicePtr ΒΆ
func ToSlicePtr[T any](collection []T) []*T
ToPtr returns a slice of pointer copy of value.
func Uniq ΒΆ
func Uniq[T comparable](collection []T) []T
Uniq returns a duplicate-free version of an array, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the array.
func UniqBy ΒΆ
func UniqBy[T any, U comparable](collection []T, iteratee func(T) U) []T
Uniq returns a duplicate-free version of an array, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the array. It accepts `iteratee` which is invoked for each element in array to generate the criterion by which uniqueness is computed.
func Unzip2 ΒΆ
Unzip2 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.
func Unzip3 ΒΆ
Unzip3 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.
func Unzip4 ΒΆ
Unzip4 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.
func Unzip5 ΒΆ
func Unzip5[A any, B any, C any, D any, E any](tuples []Tuple5[A, B, C, D, E]) ([]A, []B, []C, []D, []E)
Unzip5 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.
func Unzip6 ΒΆ
func Unzip6[A any, B any, C any, D any, E any, F any](tuples []Tuple6[A, B, C, D, E, F]) ([]A, []B, []C, []D, []E, []F)
Unzip6 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.
func Unzip7 ΒΆ
func Unzip7[A any, B any, C any, D any, E any, F any, G any](tuples []Tuple7[A, B, C, D, E, F, G]) ([]A, []B, []C, []D, []E, []F, []G)
Unzip7 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.
func Unzip8 ΒΆ
func Unzip8[A any, B any, C any, D any, E any, F any, G any, H any](tuples []Tuple8[A, B, C, D, E, F, G, H]) ([]A, []B, []C, []D, []E, []F, []G, []H)
Unzip8 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.
func Unzip9 ΒΆ
func Unzip9[A any, B any, C any, D any, E any, F any, G any, H any, I any](tuples []Tuple9[A, B, C, D, E, F, G, H, I]) ([]A, []B, []C, []D, []E, []F, []G, []H, []I)
Unzip9 accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.
func Values ΒΆ
func Values[K comparable, V any](in map[K]V) []V
Values creates an array of the map values.
Types ΒΆ
type Clonable ΒΆ
type Clonable[T any] interface { Clone() T }
Clonable defines a constraint of types having Clone() T method.
type Entry ΒΆ
type Entry[K comparable, V any] struct { Key K Value V }
Entry defines a key/value pairs.
func Entries ΒΆ
func Entries[K comparable, V any](in map[K]V) []Entry[K, V]
Entries transforms a map into array of key/value pairs.
type Tuple2 ΒΆ
Tuple2 is a group of 2 elements (pair).
type Tuple3 ΒΆ
Tuple3 is a group of 3 elements.
type Tuple4 ΒΆ
Tuple4 is a group of 4 elements.
type Tuple5 ΒΆ
Tuple5 is a group of 5 elements.
func Zip5 ΒΆ
func Zip5[A any, B any, C any, D any, E any](a []A, b []B, c []C, d []D, e []E) []Tuple5[A, B, C, D, E]
Zip5 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
type Tuple6 ΒΆ
Tuple6 is a group of 6 elements.
func Zip6 ΒΆ
func Zip6[A any, B any, C any, D any, E any, F any](a []A, b []B, c []C, d []D, e []E, f []F) []Tuple6[A, B, C, D, E, F]
Zip6 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
type Tuple7 ΒΆ
Tuple7 is a group of 7 elements.
func Zip7 ΒΆ
func Zip7[A any, B any, C any, D any, E any, F any, G any](a []A, b []B, c []C, d []D, e []E, f []F, g []G) []Tuple7[A, B, C, D, E, F, G]
Zip7 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
type Tuple8 ΒΆ
type Tuple8[A any, B any, C any, D any, E any, F any, G any, H any] struct { A A B B C C D D E E F F G G H H }
Tuple8 is a group of 8 elements.
func Zip8 ΒΆ
func Zip8[A any, B any, C any, D any, E any, F any, G any, H any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H) []Tuple8[A, B, C, D, E, F, G, H]
Zip8 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.
type Tuple9 ΒΆ
type Tuple9[A any, B any, C any, D any, E any, F any, G any, H any, I any] struct { A A B B C C D D E E F F G G H H I I }
Tuple9 is a group of 9 elements.
func Zip9 ΒΆ
func Zip9[A any, B any, C any, D any, E any, F any, G any, H any, I any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, i []I) []Tuple9[A, B, C, D, E, F, G, H, I]
Zip9 creates a slice of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. When collections have different size, the Tuple attributes are filled with zero value.