array

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 0 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[K any](values []K, fn func(value K, index int) bool) []K

Filter filters the array using the function fn.

func Find

func Find[T comparable](elements []T, compare func(element T, index int) bool) (T, bool)

Find searches an element in a slice based on a predicated. It returns element and true if element was found.

func ForEach

func ForEach[K any](values []K, fn func(value K, index int))

ForEach iterates the value of slice.

func GroupBy

func GroupBy[T any, K comparable](values []T, iteratee func(value T, index int) K) map[K][]T

func Includes

func Includes[K comparable](values []K, value K) bool

Includes returns true if the array contains the value.

func Map

func Map[K any, R any](values []K, fn func(value K, index int) R) []R

Map applies the function fn to each value in the array and returns a new array with the results.

func Reduce

func Reduce[K any, R any](values []K, fn func(all R, value K, index int) R, initialValue R) R

Reduce returns the result of applying the function fn to each value in the array and an accumulator, starting with the initial value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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