Skip to content

Commit 27ab176

Browse files
committed
update arrays reduce
1 parent ad5f681 commit 27ab176

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arrays/arrays.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ func MapIndex[S, T any](items []S, fn func(S, int) T) []T {
4545
}
4646

4747
// Reduce applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value.
48-
func Reduce[S, T any](items []S, fn func(T, S) T, acc T) T {
48+
func Reduce[S, T any](items []S, acc T, fn func(S, T) T) T {
4949
for _, value := range items {
50-
acc = fn(acc, value)
50+
acc = fn(value, acc)
5151
}
5252
return acc
5353
}

0 commit comments

Comments
 (0)