Documentation ¶
Index ¶
- func All[T any](in []T, fn func(v T, idx int) bool) bool
- func Any[T any](in []T, fn func(v T, idx int) bool) bool
- func Copy[T any](in []T) []T
- func Count[T any](in []T, fn func(v T, idx int) bool) int
- func Filter[T any](in []T, fn func(v T, idx int) bool) []T
- func FindIndex[T any](in []T, fn func(v T, idx int) bool) int
- func Map[T, R any](in []T, fn func(v T, idx int) R) []R
- func None[T any](in []T, fn func(v T, idx int) bool) bool
- func Range[T any](in []T, fn func(v T, idx int))
- func RangeErr[T any](in []T, fn func(v T, idx int) error) (int, error)
- func Reduce[T, R any](in []T, fn func(v T, acc R) R) R
- func ReduceSeed[T, R any](in []T, seed R, fn func(v T, acc R) R) R
- func Sort[T any](in []T, less func(s []T, i, j int) bool) []T
- func SortStable[T any](in []T, less func(s []T, i, j int) bool) []T
- func SplitBy[T any](in []T, fn func(v T, idx int) bool) (t []T, f []T)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
All will apply given test func on each input and assert that all of the inputs pass the test. It return on first failed assertion.
func Any ¶
Any will apply given test func on each input and assert that any of the inputs passes the test. It returns on first succeeded assertion.
func FindIndex ¶
FindIndex will search with given test func. When the test is positive it will return its index and `-1` otherwise.
func None ¶
None will apply given test func on each input and assert that none of the inputs passes the test. It returns on first failed assertion.
func RangeErr ¶
RangeErr will range over given input and apply the given callback func on each element. It will fail on first error, returning the emitted error and the index which failed. If no error was emitted the returned index will be `-1`.
func Reduce ¶
func Reduce[T, R any](in []T, fn func(v T, acc R) R) R
Reduce will apply a reduce operation on the input. The seed value of the accumulator will be its zero value.
func ReduceSeed ¶
func ReduceSeed[T, R any](in []T, seed R, fn func(v T, acc R) R) R
ReduceSeed will apply a reduce operation on the input with given seed value for the accumulator.
func Sort ¶
Sort will sort a shallow copy of the given input based on given "less" func, leaving the input untouched. Within the "less" func you have to use the injected reference of the slice.
func SortStable ¶
Sort will sort a shallow copy of the given input based on given "less" func, leaving the input untouched. Within the "less" func you have to use the injected reference of the slice.
Types ¶
This section is empty.