Files
lo/docs/data/core-reduceright.md
T
2025-10-06 17:15:49 +02:00

736 B

name, slug, sourceRef, category, subCategory, playUrl, variantHelpers, similarHelpers, position, signatures
name slug sourceRef category subCategory playUrl variantHelpers similarHelpers position signatures
ReduceRight reduceright slice.go#L97 core slice https://go.dev/play/p/Fq3W70l7wXF
core#slice#reduceright
core#slice#reduce
core#slice#sum
core#slice#product
core#slice#mean
core#slice#max
core#slice#min
60
func ReduceRight[T any, R any](collection []T, accumulator func(agg R, item T, index int) R, initial R) R

Like Reduce except it iterates from right to left and accumulates into a single value.

result := lo.ReduceRight([][]int{{0, 1}, {2, 3}, {4, 5}}, func(agg []int, item []int, _ int) []int {
    return append(agg, item...)
}, []int{})
// []int{4, 5, 2, 3, 0, 1}