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,33 @@
|
||||
---
|
||||
name: partition
|
||||
kind: function
|
||||
lang: go
|
||||
domain: core
|
||||
version: "1.0.0"
|
||||
purity: pure
|
||||
signature: "func Partition[T any](xs []T, pred func(T) bool) ([]T, []T)"
|
||||
description: "Divide un slice en dos segun un predicado. El primer slice contiene los elementos que cumplen el predicado, el segundo los que no. Se preserva el orden original."
|
||||
tags: [slice, partition, functional, generic]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: ""
|
||||
imports: []
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "functions/core/partition.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```go
|
||||
evens, odds := Partition([]int{1, 2, 3, 4, 5}, func(n int) bool { return n%2 == 0 })
|
||||
// evens = [2, 4]
|
||||
// odds = [1, 3, 5]
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Funcion pura generica. Ambos slices retornados son nuevos (no muta el slice original). Si el slice de entrada esta vacio, retorna dos slices vacios. Los elementos mantienen su orden relativo original en cada particion.
|
||||
Reference in New Issue
Block a user