slice

package
v0.0.0-...-77861b7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2023 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[T any](input []T, pred func(T) bool) (output []T)

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 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL