20 lines
310 B
Go
20 lines
310 B
Go
package learning
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
)
|
|
|
|
func compute(fn func(float64, float64) float64) float64 {
|
|
return fn(3, 4)
|
|
}
|
|
|
|
func FuncAsValues() {
|
|
hypot := func(x, y float64) float64 {
|
|
return math.Sqrt(x*x + y*y)
|
|
}
|
|
fmt.Println(hypot(5,12))
|
|
|
|
fmt.Println(compute(hypot))
|
|
fmt.Println(compute(math.Pow))
|
|
}
|