iT邦幫忙

0

Javascript SICP 1.3 - Formulating Abstractions with Higher-Order Functions

  • 分享至 

  • xImage
  •  

圖片摘錄 https://www.comp.nus.edu.sg/~cs1101s/sicp/

Functions as Arguments

首先觀察以下三個function

  1. Sum of the integers from a through b

https://ithelp.ithome.com.tw/upload/images/20190509/201175164sW32xYjlD.png

  1. Sum of the cubes of the integers from a through b

https://ithelp.ithome.com.tw/upload/images/20190509/20117516ar26zlhquP.png

  1. Sum of a sequence of terms in the series

https://ithelp.ithome.com.tw/upload/images/20190509/20117516uWZVuYMOUY.png
https://ithelp.ithome.com.tw/upload/images/20190509/20117516Kgh6oAgEJ3.png

以上三個function其實可以統整成以下模式:
https://ithelp.ithome.com.tw/upload/images/20190509/201175169Qt5djiMiF.png

可以發現其實只有兩個部分naming, term,而這就是鼎鼎大名的數學表示式:** sigma notation **

https://ithelp.ithome.com.tw/upload/images/20190509/20117516dOPUbD544c.png

Sigma notation的強大在於,可以處理函數自己的加總,而非加總特定部分。

Comment Template:
https://ithelp.ithome.com.tw/upload/images/20190509/20117516wEbv81bGcP.png

應用

  1. sum_cube

https://ithelp.ithome.com.tw/upload/images/20190509/20117516AnxQnBLilz.png

  1. pi_sum

https://ithelp.ithome.com.tw/upload/images/20190509/20117516IcmalyYRUq.png

  1. integral

https://ithelp.ithome.com.tw/upload/images/20190509/20117516ayH1ciBbs8.png

來做習題摟~~

https://ithelp.ithome.com.tw/upload/images/20190509/20117516ImpqTmIC59.pnghttps://ithelp.ithome.com.tw/upload/images/20190509/20117516A4kyy99im6.pnghttps://ithelp.ithome.com.tw/upload/images/20190509/20117516tWQxuIAj6L.pnghttps://ithelp.ithome.com.tw/upload/images/20190509/20117516HNwhrdB8jj.pnghttps://ithelp.ithome.com.tw/upload/images/20190509/201175163RJG2BiFAz.pnghttps://ithelp.ithome.com.tw/upload/images/20190509/201175167RgKSWh8W3.png


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言