Documentation
¶
Overview ¶
Package folders defines the folders API and a library of folders implementations. These functions can be used with various Fold methods in the other packages in this library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LargestFolder ¶
LargestFolder returns the largest of a given value and an accumulator value.
Types ¶
type Folder ¶
Folder is a function that can transform a source value and store it in a target value. The various Fold functions will call a Folder repeatedly feeding the value in the returned result as the accumulator each call.
func NewCountingFolder ¶
NewCountingFolder returns a new Folder function that increments the accumulator value by the given step amount for each element folded over. The elements are ignored.
func NewMapFolder ¶
func NewMapFolder[S any, K comparable, V any]( toKey ToKey[S, K], toValue ToValue[S, V], ) Folder[map[K]V, S]
NewMapFolder returns a new Folder function that takes two functions, applies the toKey function and toValue function to the element being folded over and sets the resulting key to be the resulting value in the provided accumulator map.
func NewMatchesFolder ¶
NewMatchesFolder returns a new Folder function that applies a Filter function to a given value and appends it to a provided accumulator slice for a match.
func NewSliceFolder ¶
NewSliceFolder returns a new Folder function that appends each element folded over to the accumulator slice. This is similar to calling append(accumulator, slice...) except that this folder can be used in a call to sliceutils.Fold*.
type FolderNoError ¶
type FolderNoError[T, S any] func(accumulator T, source S) T
FolderNoError is a function that can transform a source value and store it in a target value. The various Fold functions will call a FolderNoError repeatedly feeding the returned value as the accumulator each call.
func NewMatchesFolderNoError ¶
func NewMatchesFolderNoError[T any](filter filters.FilterNoError[T]) FolderNoError[[]T, T]
NewMatchesFolderNoError returns a new Folder function that applies a Filter function to a given value and appends it to a provided accumulator slice for a match.