github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/op/delay/sum/api.go (about)

     1  // Package sum provides sum.Of alias
     2  package sum
     3  
     4  import (
     5  	"github.com/m4gshm/gollections/c"
     6  	"github.com/m4gshm/gollections/loop"
     7  	"github.com/m4gshm/gollections/slice/sum"
     8  )
     9  
    10  // Of returns a sum builder function
    11  func Of[T c.Summable](elements ...T) func() T {
    12  	return func() T { return sum.Of(elements) }
    13  }
    14  
    15  // Over returns a sum builder function
    16  func Over[T c.Summable](getters ...func() T) func() T {
    17  	return func() T { return loop.Sum(loop.Convert(loop.Of(getters...), func(e func() T) T { return e() })) }
    18  }