We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
其中 goodenough 的判断应该是 <.
goodenough
<
goodenough 为 true 的条件应该是 old-guess 和 new-guess 足够接近, 所以应该是差的绝对值越小越好. 而且如果使用 >, 大部分情况下, 例如 x = 2, 在第一轮判断中, old-guess = 1, new-guess = 1.5. 则绝对值的差为 0.5, 大于 0.01, 直接跳出递归.
true
old-guess
new-guess
>
x = 2
old-guess = 1
new-guess = 1.5
(define (good-enough? old-guess new-guess) (< 0.01 (/ (abs (- new-guess old-guess)) old-guess)))
考虑到不对原有定义的破坏, 我建议将 old-guess 和 new-guess 的比较放在 goodenough 中处理, 如下:
(define (goodenough? guess x) (< (/ (abs (- guess (improve guess x))) guess) (expt 0.1 4)))
完整的代码可以点击这里, 供参考.
The text was updated successfully, but these errors were encountered:
make a correct predicate
a54abfe
I want to resolve huangzworks#50 issue. The predicate should be "less than".
Successfully merging a pull request may close this issue.
其中
goodenough
的判断应该是<
.goodenough
为true
的条件应该是old-guess
和new-guess
足够接近, 所以应该是差的绝对值越小越好. 而且如果使用>
, 大部分情况下, 例如x = 2
, 在第一轮判断中,old-guess = 1
,new-guess = 1.5
. 则绝对值的差为 0.5, 大于 0.01, 直接跳出递归.考虑到不对原有定义的破坏, 我建议将 old-guess 和 new-guess 的比较放在 goodenough 中处理, 如下:
完整的代码可以点击这里, 供参考.
The text was updated successfully, but these errors were encountered: