Discover Packages
github.com/M15t/gram
pkg
util
sliceutil
package
Version:
v0.0.12
Opens a new window with list of versions in this module.
Published: May 14, 2024
License: LGPL-2.1
Opens a new window with license information.
Imports: 0
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
Documentation
¶
Package sliceutil provides a collection of slice utility functions, including descriptive statistics functions for numerical slices.
func Filter[S ~[]E, E any](s S, f func(int, E) bool) S
func Map[S ~[]E, E any, U any](s S, f func(int, E) U) []U
func Reduce[S ~[]E, E any, U any](s S, init U, f func(int, E, U) U) U
func Filter[S ~[]E, E any ](s S, f func(int , E) bool ) S
Filter returns a new slice containing
only the elements in the input slice s for which the specified function f is true.
func Map[S ~[]E, E any , U any ](s S, f func(int , E) U) []U
Map returns a new slice that contains
each of the elements of the input slice s mutated by the specified function.
func Reduce[S ~[]E, E any , U any ](s S, init U, f func(int , E, U) U) U
Reduce applies the reducing function f
to each element of the input slice s, and returns the value of the last call to f.
The first parameter of the reducing function f is initialized with init.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.