Documentation
¶
Overview ¶
Package lang provides some helpful or at least amusing language features not included in the standard Go language or libraries.
Index ¶
- func Critical(mutex Mutex, f func())
- func CriticalGet[T any](mutex Mutex, f func() T) T
- func Filter[A comparable](input []A, items ...A) []A
- func FilterFunc[A any](input []A, f func(A) bool) []A
- func Head[A any](input []A, count int) []A
- func Map[A, B any](input []A, f func(A) B) []B
- func Maybe[T any](b bool, value T, fallback T) T
- func Tail[A any](input []A, count int) []A
- type Mutex
- type Pair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Critical ¶ added in v0.0.8
func Critical(mutex Mutex, f func())
Critical executes f while holding the mutex.
func CriticalGet ¶ added in v0.0.8
CriticalGet executes f while holding the mutex, and returns the return value of f.
func Filter ¶ added in v0.0.7
func Filter[A comparable](input []A, items ...A) []A
Filter removes the list of items from input.
Note that Filter yields a deep copy.
func FilterFunc ¶ added in v0.0.7
FilterFunc uses f to remove elements from input. If f returns true for an element, that element is not included in the result.
Note that FilterFunc creates a deep copy.
func Head ¶ added in v0.0.5
Head returns up to the first count elements in the given input slice.
Note that this is yields a shallow copy.
func Map ¶ added in v0.0.3
func Map[A, B any](input []A, f func(A) B) []B
Map applies function f to every A element in input to create a new slice of type B.