fast-exp 中的 SICP 1.2.4 错字? [英] SICP 1.2.4 typo in fast-exp?

查看:48
本文介绍了fast-exp 中的 SICP 1.2.4 错字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 SICP,我不确定这是书中的错误还是我遗漏了什么.

I am going through SICP and I am not sure if this is a mistake in the book or maybe I missed something.

为了计算fast-exp,作者给出了以下规则:

For calculating fast-exp authors gave the following rules:

b^n = (b^(b/2))^2 如果 n 是偶数

b^n = (b^(b/2))^2 if n is even

b^n = b * b^(n - 1) 如果 n 是奇数

b^n = b * b^(n - 1) if n is odd

然而,当他们展示偶数 n 的实现时,我们有:

However when they present the implementation for the even n we have:

((even? n) (square (fast-expt b (/ n 2))))

我认为这是正确的.

我相信

b^n = (b^(b/2))^2 如果 n 是偶数

应该改为

b^n = (b^(n/2))^2 如果 n 是偶数.

我很难相信这么老的书中竟然有这样的错误.我也试图在网上找到关于这个问题的任何讨论,但失败了.不知道这里发生了什么.提前致谢.

It is hard for me to believe that in so old book there is such mistake. I also tried to find any discussion about this issue on the web but failed. Not sure what is going on here. Thanks in advance.

上述链接章节

推荐答案

你说得对,这是一个错字 - 公式应该是 (b^(n/2))^2 if n 是偶数.但它已在勘误中得到纠正.

You're right, it's a typo - the formula should be (b^(n/2))^2 if n is even. But it has been corrected in the errata.

这篇关于fast-exp 中的 SICP 1.2.4 错字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆