package
Version:
v0.0.36
Opens a new window with list of versions in this module.
Published: Nov 12, 2023
License: Apache-2.0
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 1
Opens a new window with list of known importers.
Documentation
¶
-
func Filter[T any](inputs []T, filter FilterFn[T]) []T
-
func Find[T any](inputs []T, filter FilterFn[T]) *T
-
func Flat[T any](inputs [][]T) []T
-
func ForEach[T any](inputs []T, fn ForEachFn[T]) error
-
func Map[Input, Output any](inputs []Input, mapper MapFn[Input, Output]) ([]Output, error)
-
func Reduce[Accumulator, T any](inputs []T, initializer Accumulator, reducer ReduceFn[Accumulator, T]) (*Accumulator, error)
-
type FilterFn
-
type ForEachFn
-
type MapFn
-
type ReduceFn
Returns an array of elements for which the filter evaluated to true
Returns the first element for which the filter evaluated to true or nil if none found
func Flat[T any](inputs [][]T) []T
Flattens nested arrays
Executes fn for each element in the array
Returns early if an error is returned
func Map[Input, Output any](inputs []Input, mapper MapFn[Input, Output]) ([]Output, error)
Executes mapper for each element, returning the result
Returns early if an error is returned
func Reduce[Accumulator, T any](inputs []T, initializer Accumulator, reducer ReduceFn[Accumulator, T]) (*Accumulator, error)
Executes reducer for each element, the result being included in the parameter of the next execution
Returns early if an error is given
type FilterFn[T any] func(element T, index int) bool
type MapFn[Input, Output any] func(element Input, index int) (Output, error)
type ReduceFn[Accumulator, T any] func(accumulator Accumulator, element T, index int) (Accumulator, error)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.