5ef3cda890
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>
12 lines
290 B
Go
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
|
|
}
|