package generic
import "github.com/IBM/fp-go/function/generic"
Index ¶
- func CacheCallback[ EM ~func(F) F, LLT ~func() LT, LT ~func() T, F ~func(A) T, KF func(A) K, C ~func(K, LLT) LT, A any, K comparable, T any](kf KF, getOrCreate C) EM
- func ContramapMemoize[F ~func(A) T, KF func(A) K, A any, K comparable, T any](kf KF) func(F) F
- func Memoize[F ~func(K) T, K comparable, T any](f F) F
- func SingleElementCache[ LLT ~func() LT, K comparable, LT ~func() T, T any, ]() func(K, LLT) LT
- func Switch[HF ~func(T) R, N ~map[K]HF, KF ~func(T) K, K comparable, T, R any](kf KF, n N, d HF) HF
Functions ¶
func CacheCallback ¶
func CacheCallback[ EM ~func(F) F, LLT ~func() LT, LT ~func() T, F ~func(A) T, KF func(A) K, C ~func(K, LLT) LT, A any, K comparable, T any](kf KF, getOrCreate C) EM
CacheCallback converts a unary function into a unary function that caches the value depending on the parameter
func ContramapMemoize ¶
func ContramapMemoize[F ~func(A) T, KF func(A) K, A any, K comparable, T any](kf KF) func(F) F
ContramapMemoize converts a unary function into a unary function that caches the value depending on the parameter
func Memoize ¶
func Memoize[F ~func(K) T, K comparable, T any](f F) F
Memoize converts a unary function into a unary function that caches the value depending on the parameter
func SingleElementCache ¶
func SingleElementCache[ LLT ~func() LT, K comparable, LT ~func() T, T any, ]() func(K, LLT) LT
SingleElementCache is a cache with a capacity of a single element
func Switch ¶
func Switch[HF ~func(T) R, N ~map[K]HF, KF ~func(T) K, K comparable, T, R any](kf KF, n N, d HF) HF
Switch applies a handler to different cases. The handers are stored in a map. A key function extracts the case from a value.
Source Files ¶
- Version
- v1.0.151 (latest)
- Published
- Nov 23, 2024
- Platform
- linux/amd64
- Imports
- 2 packages
- Last checked
- 2 months ago –
Tools for package owners.