1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-06-17 00:07:49 +02:00

fix: implement FoldMap

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2023-08-10 18:08:11 +02:00
parent 39c6108bf5
commit 1b1dccc551
11 changed files with 306 additions and 1 deletions

View File

@ -294,3 +294,13 @@ func SliceRight[A any](start int) func([]A) []A {
func Copy[A any](b []A) []A {
return G.Copy(b)
}
// FoldMap maps and folds an array. Map the Array passing each value to the iterating function. Then fold the results using the provided Monoid.
func FoldMap[A, B any](m M.Monoid[B]) func(func(A) B) func([]A) B {
return G.FoldMap[[]A](m)
}
// Fold folds the array using the provided Monoid.
func Fold[A any](m M.Monoid[A]) func([]A) A {
return G.Fold[[]A](m)
}