Upgrade to Pro — share decks privately, control downloads, hide ads and more …

談談_Functional_Programming.pdf

 談談_Functional_Programming.pdf

CypressKuo

August 30, 2019
Tweet

More Decks by CypressKuo

Other Decks in Technology

Transcript

  1. Pure Function 結合 no side effect 與 Referential transparency 一個

    function 給予相同的參數, 永遠會回傳相同的返回值,並且沒有任何顯著的副作用。
  2. 🍎 + 🍎 = 🍎🍎 🍌 + 🍌 = 🍌🍌

    (🍎🍎) + (🍎🍎) + (🍎🍎) = 🍎🍎🍎🍎🍎🍎 (🍌🍌) + (🍌🍌) + (🍌🍌) = 🍌🍌🍌🍌🍌🍌 抽象化
  3. 1 + 1 = 2 進一步 => fn(1, 1) ->

    2 // fn = (a, b) => a + b; 2 + 2 + 2 = 6 進一步 => 2 * 3 = 6 再進一步 => fn(2, 3) -> 6 // fn = (a, b) => a * b; 抽象化
  4. If all you have is a hammer, everything looks like

    a nail. 活用工具,不是被工具所用。 結論