github.com/tobgu/qframe@v0.4.0/internal/icolumn/aggregations.go (about) 1 package icolumn 2 3 import "github.com/tobgu/qframe/internal/math/integer" 4 5 var aggregations = map[string]func([]int) int{ 6 "sum": sum, 7 "max": max, 8 "min": min, 9 } 10 11 func sum(values []int) int { 12 result := 0 13 for _, v := range values { 14 result += v 15 } 16 return result 17 } 18 19 func max(values []int) int { 20 result := values[0] 21 for _, v := range values[1:] { 22 result = integer.Max(result, v) 23 } 24 return result 25 } 26 27 func min(values []int) int { 28 result := values[0] 29 for _, v := range values[1:] { 30 result = integer.Min(result, v) 31 } 32 return result 33 }