github.com/l3x/learn-fp-go@v0.0.0-20171228022418-7639825d0b71/4-purely-functional/ch09-functor-monoid/03_generics_nums/src/num/int32_slice.go (about)

     1  // Generated by: gen
     2  // TypeWriter: slice
     3  // Directive: +gen on Int32
     4  
     5  package num
     6  
     7  // Int32Slice is a slice of type Int32. Use it where you would use []Int32.
     8  type Int32Slice []Int32
     9  
    10  // SumInt32 sums Int32 over elements in Int32Slice. See: http://clipperhouse.github.io/gen/#Sum
    11  func (rcv Int32Slice) SumInt32(fn func(Int32) Int32) (result Int32) {
    12  	for _, v := range rcv {
    13  		result += fn(v)
    14  	}
    15  	return
    16  }