Functions As Values
func add(x, y int) int {
return x + y
}
func mul(x, y int) int {
return x * y
}func aggregate(a, b, c int, arithmetic func(int, int) int) int {
firstResult := arithmetic(a, b)
secondResult := arithmetic(firstResult, c)
return secondResult
}func main() {
sum := aggregate(2, 3, 4, add)
// sum is 9
product := aggregate(2, 3, 4, mul)
// product is 24
}