package iter
import "github.com/sourcegraph/conc/iter"
Index ¶
- func ForEach[T any](input []T, f func(*T))
- func ForEachIdx[T any](input []T, f func(int, *T))
- func Map[T, R any](input []T, f func(*T) R) []R
- func MapErr[T any, R any](input []T, f func(*T) (R, error)) ([]R, error)
Functions ¶
func ForEach ¶
func ForEach[T any](input []T, f func(*T))
ForEach executes f in parallel over each element in input.
It is safe to mutate the input parameter, which makes it possible to map in place.
ForEach always uses at most runtime.GOMAXPROCS goroutines. It takes roughly 2µs to start up the goroutines and adds an overhead of roughly 50ns per element of input.
func ForEachIdx ¶
ForEachIdx is the same as ForEach except it also provides the index of the element to the callback.
func Map ¶
func Map[T, R any](input []T, f func(*T) R) []R
Map applies f to each element of input, returning the mapped result.
func MapErr ¶
MapErr applies f to each element of the input, returning the mapped result and a combined error of all returned errors.
Source Files ¶
- Version
- v0.1.0
- Published
- Jan 2, 2023
- Platform
- js/wasm
- Imports
- 5 packages
- Last checked
- 3 hours ago –
Tools for package owners.