fn: remove redundant Reduce function

This commit removes Reduce since we already have both Foldl and Foldr.
This commit is contained in:
Keagan McClelland 2024-07-10 16:59:43 -07:00
parent fa2e25d5f4
commit eaa5e4a039
No known key found for this signature in database
GPG Key ID: FA7E65C951F12439

View File

@ -1,17 +0,0 @@
package fn
// Reducer represents a function that takes an accumulator and the value, then
// returns a new accumulator.
type Reducer[T, V any] func(accum T, value V) T
// Reduce takes a slice of something, and a reducer, and produces a final
// accumulated value.
func Reduce[T any, V any, S []V](s S, f Reducer[T, V]) T {
var accum T
for _, x := range s {
accum = f(accum, x)
}
return accum
}