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:
@@ -0,0 +1,13 @@
|
||||
package core
|
||||
|
||||
// Pipeline composes a sequence of functions T -> T into a single function.
|
||||
// The functions are applied left to right: Pipeline(f, g, h)(x) == h(g(f(x))).
|
||||
// Returns the identity function if no functions are provided.
|
||||
func Pipeline[T any](fns ...func(T) T) func(T) T {
|
||||
return func(val T) T {
|
||||
for _, fn := range fns {
|
||||
val = fn(val)
|
||||
}
|
||||
return val
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user