Documentation ¶
Index ¶
- func Filter[T any](input []T, pred func(T) bool) (output []T)
- func Map[T1, T2 any](input []T1, f func(T1) T2) (output []T2)
- func MapConcurrent[T1, T2 any](input []T1, f func(T1) T2) (output []T2)
- func MapConcurrentWithContext[T1, T2 any](ctx context.Context, input []T1, f func(T1) T2) (output []T2)
- func Reduce[T1, T2 any](input []T1, f func(T2, T1) T2) T2
- func ReduceWithInitialValue[T1, T2 any](input []T1, acc T2, f func(T2, T1) T2) T2
- func ToChan[T any](in []T) <-chan T
- func ToChanWithContext[T any](ctx context.Context, in []T) <-chan T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
Filter returns a new slice with all elements from the from the input elements for which the provided predicate function returns true.
func Map ¶
func Map[T1, T2 any](input []T1, f func(T1) T2) (output []T2)
Map returns a new slice populated with the result of calling the provided function on every element in the provided input slice.
func MapConcurrent ¶
func MapConcurrent[T1, T2 any](input []T1, f func(T1) T2) (output []T2)
MapConcurrent does the same as Map, but concurrently.
func MapConcurrentWithContext ¶
func MapConcurrentWithContext[T1, T2 any](ctx context.Context, input []T1, f func(T1) T2) (output []T2)
MapConcurrentWithContext does the same as Map, but concurrently, and receives a context.Context to be cancellable.
func Reduce ¶
func Reduce[T1, T2 any](input []T1, f func(T2, T1) T2) T2
Reduce executes a provided function on each element of the slice in order, passing the return value of the previous function call on the preceding slice element. The final result of running the provided function across all slice elements is returned.
func ReduceWithInitialValue ¶
func ReduceWithInitialValue[T1, T2 any](input []T1, acc T2, f func(T2, T1) T2) T2
ReduceWithInitialValue executes a provided function on each element of the slice in order, passing the return value of the previous function call on the preceding slice element. Unlike Reduce, the initial value of the accumulator can be provided as an argument. The final result of running the provided function across all slice elements is returned.
func ToChan ¶
func ToChan[T any](in []T) <-chan T
ToChan returns a chan that produces all elements of the provided input slice in order.
func ToChanWithContext ¶
ToChanWithContext does the same as ToChan, but is cancellable through the provided context.Context object.
Types ¶
This section is empty.