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

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