嗨,我正在阅读 SICP,我被困在练习 1.7 中:
这是我的代码:
(define (avg x y)
(/ (+ x y) 2))
;;(avg 1 2)
(define (square x)
(* x x))
;;(square 2)
(define (improve guess x)
(avg guess (/ x guess)))
;;(improve 1 2)
(define (good-enough? x guess)
(< (abs (- guess ((avg guess (/ x guess))))) 0.1))
(define (sqrt-iter guess x)
(if (good-enough? guess x)
guess
(sqrt-iter (improve guess x)
x)))
(define (my-sqrt x)
(sqrt-iter 1.0 x))
(my-sqrt 100)
DrRacket 给出了一个错误:
函数调用:在左括号后需要一个函数,但收到 50.005
这是什么意思以及如何解决这个问题?