feat: statistics: finish dev
This commit is contained in:
17
utils/list.go
Normal file
17
utils/list.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package utils
|
||||
|
||||
type ObjectType []interface{}
|
||||
|
||||
func ForEach[T any](arr *[]T, fun func(item *T)) {
|
||||
for i := range *arr {
|
||||
fun(&((*arr)[i]))
|
||||
}
|
||||
}
|
||||
|
||||
func Map[T any, V any](arr []T, fun func(item T) V) []V {
|
||||
res := make([]V, 0, len(arr))
|
||||
for _, item := range arr {
|
||||
res = append(res, fun(item))
|
||||
}
|
||||
return res
|
||||
}
|
||||
Reference in New Issue
Block a user