mirror of
https://github.com/IBM/fp-go.git
synced 2025-08-10 22:31:32 +02:00
Dependency injection (#81)
* fix: checkin Signed-off-by: Carsten Leue <carsten.leue@de.ibm.com> * fix: add initial DI implementation Signed-off-by: Carsten Leue <carsten.leue@de.ibm.com> * fix: add multi provider Signed-off-by: Carsten Leue <carsten.leue@de.ibm.com> * fix: simplify DI implementation Signed-off-by: Carsten Leue <carsten.leue@de.ibm.com> * fix: simplify provider Signed-off-by: Carsten Leue <carsten.leue@de.ibm.com> * fix: add Switch to function package Signed-off-by: Carsten Leue <carsten.leue@de.ibm.com> * fix: add DI Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com> --------- Signed-off-by: Carsten Leue <carsten.leue@de.ibm.com> Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
@@ -49,6 +49,11 @@ func Collect[K comparable, V, R any](f func(K, V) R) func(map[K]V) []R {
|
||||
return G.Collect[map[K]V, []R](f)
|
||||
}
|
||||
|
||||
// CollectOrd applies a collector function to the key value pairs in a map and returns the result as an array
|
||||
func CollectOrd[V, R any, K comparable](o ord.Ord[K]) func(func(K, V) R) func(map[K]V) []R {
|
||||
return G.CollectOrd[map[K]V, []R](o)
|
||||
}
|
||||
|
||||
func Reduce[K comparable, V, R any](f func(R, V) R, initial R) func(map[K]V) R {
|
||||
return G.Reduce[map[K]V](f, initial)
|
||||
}
|
||||
|
Reference in New Issue
Block a user