feat: 6 funciones core — retry, memoize, pipeline, map_concurrent, partition, chunk

Funciones genericas reutilizables:
- RetryWithBackoff: reintento con backoff exponencial (impure)
- Memoize: cache de funciones puras (pure)
- Pipeline: composición T→T en secuencia (pure)
- MapConcurrent: map paralelo con worker pool (impure)
- Partition: divide slice en dos por predicado (pure)
- Chunk: divide slice en trozos de tamaño N (pure)
Todas con implementación real y documentación .md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-28 02:23:26 +01:00
parent 0f9a72dfc9
commit 16e34a806e
12 changed files with 362 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
package core
// Partition splits xs into two slices: the first contains elements where pred returns true,
// the second contains elements where pred returns false. Original order is preserved in both.
func Partition[T any](xs []T, pred func(T) bool) ([]T, []T) {
trueSlice := make([]T, 0)
falseSlice := make([]T, 0)
for _, x := range xs {
if pred(x) {
trueSlice = append(trueSlice, x)
} else {
falseSlice = append(falseSlice, x)
}
}
return trueSlice, falseSlice
}