12 lines
194 B
Go
12 lines
194 B
Go
package slices
|
|
|
|
func Search[T any](slice []T, f func(a, b T) T) T {
|
|
if len(slice) == 0 {
|
|
return *new(T)
|
|
}
|
|
|
|
value := slice[0]
|
|
Each(slice, func(v T) { value = f(value, v) })
|
|
return value
|
|
}
|