slice icon indicating copy to clipboard operation
slice copied to clipboard

feat: change `slice.Reduce` return type

Open scorsi opened this issue 3 years ago • 1 comments

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,

scorsi avatar May 23 '22 10:05 scorsi

@ssoroka up :)

scorsi avatar Jun 23 '22 08:06 scorsi