Documentation
¶
Overview ¶
Package util provides various helper functions.
I know that Map/Reduce/Filter isn't idiomatic Go, but I still find them very useful!
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](l []T, query T) bool
Contains checks if a slice contains a given element.
func Filter ¶
Filter iterates over a slice and returns a slice containing only the elements for which the predicate is true.
func ForEach ¶
func ForEach[T any](l []T, f func(T))
ForEach applies a function to each element in a slice.
func Map ¶
Map creates a new slice from the result of calling a function on each element of an input slice.
func Reduce ¶
Reduce applies an accumulator function from left to right on a slice with a given initial value.
func Remove ¶
func Remove[T comparable](l []T, toRemove T) []T
Remove removes all instances of an element from a slice.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.