Files
fn_registry/functions/core/map_slice.go
T
egutierrez 5ef3cda890 feat: funciones core filter_slice y map_slice
Primeras funciones reales del registry:
- filter_slice: filtra un slice con predicado, pura, generica
- map_slice: transforma cada elemento de un slice, pura, generica
Cada una con implementacion .go, documentacion .md y tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 02:10:38 +01:00

12 lines
290 B
Go

package core
// MapSlice applies fn to each element of xs and returns a new slice with the results.
// Does not mutate the original slice.
func MapSlice[T any, U any](xs []T, fn func(T) U) []U {
result := make([]U, len(xs))
for i, x := range xs {
result[i] = fn(x)
}
return result
}