updates
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user