1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-06-21 00:19:34 +02:00

fix: use endomorphism

Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
This commit is contained in:
Dr. Carsten Leue
2023-12-17 12:34:15 +01:00
parent 5caabf478c
commit 5fcd0b1595
9 changed files with 133 additions and 17 deletions

View File

@ -304,6 +304,11 @@ func Copy[AS ~[]A, A any](b AS) AS {
return buf
}
func Clone[AS ~[]A, A any](f func(A) A) func(as AS) AS {
// implementation assumes that map does not optimize for the empty array
return Map[AS, AS](f)
}
func FoldMap[AS ~[]A, A, B any](m M.Monoid[B]) func(func(A) B) func(AS) B {
return func(f func(A) B) func(AS) B {
return func(as AS) B {