Documentation ¶
Index ¶
- func Contains[E comparable](s []E, v E) bool
- func Filter[IN any, F FilterFunc[IN]](in []IN, fun F) []IN
- func First[IN any](in []IN) (IN, bool)
- func FlatMap[IN, OUT any, F FlatMapFunc[IN, OUT]](in []IN, fun F) []OUT
- func Last[IN any](in []IN) (IN, bool)
- func Map[IN, OUT any, F MapFunc[IN, OUT]](in []IN, fun F) []OUT
- func OfType[IN, T any](in []IN) []T
- func Reduce[IN, OUT any](in []IN, initializer OUT, fun AccumulatorFunc[IN, OUT]) OUT
- func Remove[IN comparable](in []IN, items ...IN) []IN
- type AccumulatorFunc
- type FilterFunc
- type FlatMapFunc
- type MapFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[E comparable](s []E, v E) bool
Contains checks for the existence of v in s.
func Filter ¶
func Filter[IN any, F FilterFunc[IN]](in []IN, fun F) []IN
Filter filters values from a slice using a filter function. Build returns a new slice with only the elements of s for which f returned true.
func FlatMap ¶
func FlatMap[IN, OUT any, F FlatMapFunc[IN, OUT]](in []IN, fun F) []OUT
FlatMap turns a []IN to a []OUT using a mapping function. This function has two type parameters, IN and OUT. This works with slices of any type.
func Map ¶
Map turns a []IN to a []OUT using a mapping function. This function has two type parameters, IN and OUT. This works with slices of any type.
func OfType ¶
func OfType[IN, T any](in []IN) []T
OfType filters values from a slice satisfying a given type.
func Reduce ¶
func Reduce[IN, OUT any]( in []IN, initializer OUT, fun AccumulatorFunc[IN, OUT], ) OUT
Reduce reduces a []IN to a single value using an accumulator function.
func Remove ¶
func Remove[IN comparable](in []IN, items ...IN) []IN
Remove removes all items from the slice in place.