Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- )
- func main() {
- f := poly([]float64{1, 2, 3, 4})
- fmt.Println(f(2))
- }
- func poly(a []float64) func(float64) float64 {
- return func(x float64) (res float64) {
- for i, aa := range a {
- res += aa * math.Pow(x, float64(len(a)-(i+1)))
- }
- return
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment