12 lines
198 B
Go
12 lines
198 B
Go
package slices
|
|
|
|
func Each[T any](slice []T, f func(T)) {
|
|
EachIndex(slice, func(_ int, v T) { f(v) })
|
|
}
|
|
|
|
func EachIndex[T any](slice []T, f func(int, T)) {
|
|
for i, v := range slice {
|
|
f(i, v)
|
|
}
|
|
}
|