This commit is contained in:
2026-02-12 14:01:43 +03:00
parent e5a3b6253d
commit ee6729e12a
8 changed files with 36 additions and 48 deletions

View File

@@ -22,27 +22,12 @@ func Max(a, b int) int {
return b
}
func Map[S, R any](f func(s S) R, s []S) []R {
out := make([]R, len(s))
for i := range s {
out[i] = f(s[i])
func Map[T, V any](ts []T, fn func(T) V) []V {
result := make([]V, len(ts))
for i, t := range ts {
result[i] = fn(t)
}
return out
}
// Deprecated
func PopSlice[S any](s []S, index int) []S {
if index == 0 {
return s[1:]
}
out := make([]S, 0)
for i, e := range s {
if i == index {
continue
}
out = append(out, e)
}
return out
return result
}
// Deprecated