You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
《簡約的軟體開發思維:用 Functional Programming 重構程式》CH12 ~ CH13
目錄
map()
filter()
reduce()
Ch12. 利用函數走訪
Code Smell: 有相似的函式實作
1.
map()
* 陣列的值可能為 null,使用
filter()
、?.
來避免拋出錯誤。練習 12-1:Mega Mart 寄送賀卡
cursomer.firstName
,cursomer.lastName
,cursomer.address
2.
filter()
如何整理過於複雜得篩選邏輯:回呼函式!
練習 12-2:Mega Mart 寄測試信件給顧客清單中的 1/3 使用者
3.
reduce()
reduce()
的常見用途:按編:這邊算是自己找的例子,不在讀書會及書中提及。
章節提問
Ch13. 串連函數式工具
章節重點
鏈式操作:將多個函數串接在一起,形成一個新的函數。
13.1 計算高消費力的最高消費金額
問題:巢狀結構不好理解
13.5 找出只消費過一次的顧客,以陣列回傳顧客的 email
點我看答案
答案是:你可以用
map()
、filter()
點我看答案
流融合(stream fusion)
流融合:
13.6 當 for loop 難以重構時
如何重構?
點我看提示
重構後的程式碼
各種練習題們
13.13 情境 :顧客購物車資料遺失,網站以陣列形式記錄所有曾出現過的商品
點我看答案
練習 13-16~19:棒球練習賽系列
章節提問
Beta Was this translation helpful? Give feedback.
All reactions