From eaa5e4a039488cb6fd230579a6426bbb5782cb70 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Wed, 10 Jul 2024 16:59:43 -0700 Subject: [PATCH] fn: remove redundant Reduce function This commit removes Reduce since we already have both Foldl and Foldr. --- fn/func.go | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 fn/func.go diff --git a/fn/func.go b/fn/func.go deleted file mode 100644 index 056f84aef..000000000 --- a/fn/func.go +++ /dev/null @@ -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 -}