Example #1
0
func ExampleReduce_mult() {
	in := []float64{-1, 3, 4}
	out := generic.Reduce(in, 1, func(a, b float64) float64 { return a * b }).(float64)
	fmt.Println(out)
	// Output: -12
}
Example #2
0
func ExampleReduce_concat() {
	in := []string{"a", "b", "c"}
	out := generic.Reduce(in, "", func(a, b string) string { return a + b }).(string)
	fmt.Println(out)
	// Output: abc
}
Example #3
0
func ExampleReduce_sum() {
	in := []int{1, 2, 3, 4}
	out := generic.Reduce(in, 0, func(a, b int) int { return a + b }).(int)
	fmt.Println(out)
	// Output: 10
}