Javascript SICP 1.3 - Formulating Abstractions with Higher-O

图片摘录 https://www.comp.nus.edu.sg/~cs1101s/sicp/

Functions as Arguments

首先观察以下三个function

Sum of the integers from a through b

http://img2.58codes.com/2024/201175164sW32xYjlD.png

Sum of the cubes of the integers from a through b

http://img2.58codes.com/2024/20117516ar26zlhquP.png

Sum of a sequence of terms in the series

http://img2.58codes.com/2024/20117516uWZVuYMOUY.png
http://img2.58codes.com/2024/20117516Kgh6oAgEJ3.png

以上三个function其实可以统整成以下模式:
http://img2.58codes.com/2024/201175169Qt5djiMiF.png

可以发现其实只有两个部分naming, term,而这就是鼎鼎大名的数学表示式:** sigma notation **

http://img2.58codes.com/2024/20117516dOPUbD544c.png

Sigma notation的强大在于,可以处理函数自己的加总,而非加总特定部分。

Comment Template:
http://img2.58codes.com/2024/20117516wEbv81bGcP.png

应用

sum_cube

http://img2.58codes.com/2024/20117516AnxQnBLilz.png

pi_sum

http://img2.58codes.com/2024/20117516IcmalyYRUq.png

integral

http://img2.58codes.com/2024/20117516ayH1ciBbs8.png

来做习题搂~~

http://img2.58codes.com/2024/20117516ImpqTmIC59.pnghttp://img2.58codes.com/2024/20117516A4kyy99im6.pnghttp://img2.58codes.com/2024/20117516tWQxuIAj6L.pnghttp://img2.58codes.com/2024/20117516HNwhrdB8jj.pnghttp://img2.58codes.com/2024/201175163RJG2BiFAz.pnghttp://img2.58codes.com/2024/201175167RgKSWh8W3.png


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章