slice
slice copied to clipboard
feat: change `slice.Reduce` return type
Hello,
I would like to see slice.Reduce returns a different type than the inner slice type. Example :
type OddEven struct {
Odd int
Even int
}
s := []int{0, 1, 2, 3, 4}
result := slice.Reduce(s2, OddEven{}, func(acc OddEven, i int, s int) OddEven {
if s%2 == 0 {
acc.Even++
} else {
acc.Odd++
}
return acc
})
Thanks,
@ssoroka up :)