Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
初探 functional programming
Search
CypressKuo
February 03, 2017
Technology
0
110
初探 functional programming
CypressKuo
February 03, 2017
Tweet
Share
More Decks by CypressKuo
See All by CypressKuo
Deep-copying.pdf
cypresskuo
0
28
CSS_for_Web_Vitals.pdf
cypresskuo
0
35
談談_Code_review.pdf
cypresskuo
0
41
REST_vs_GraphQL_今夜はご注文はどっち.pdf
cypresskuo
0
21
CSS_重構.pdf
cypresskuo
0
22
跟上_JS_的腳步-ES2020.pdf
cypresskuo
0
24
Core_Web_Vitals.pdf
cypresskuo
0
47
這個時代人人都知道的敏捷開發.pdf
cypresskuo
0
54
Webassembly.pdf
cypresskuo
0
11
Other Decks in Technology
See All in Technology
生成AI時代の開発組織・技術・プロセス 〜 ログラスの挑戦と考察 〜
itohiro73
1
310
製造業からパッケージ製品まで、あらゆる領域をカバー!生成AIを利用したテストシナリオ生成 / 20250627 Suguru Ishii
shift_evolve
PRO
1
150
TechLION vol.41~MySQLユーザ会のほうから来ました / techlion41_mysql
sakaik
0
190
Should Our Project Join the CNCF? (Japanese Recap)
whywaita
PRO
0
110
AI導入の理想と現実~コストと浸透〜
oprstchn
0
110
生成AI活用の組織格差を解消する 〜ビジネス職のCursor導入が開発効率に与えた好循環〜 / Closing the Organizational Gap in AI Adoption
upamune
5
4.1k
AIエージェント最前線! Amazon Bedrock、Amazon Q、そしてMCPを使いこなそう
minorun365
PRO
15
5.4k
Claude Code Actionを使ったコード品質改善の取り組み
potix2
PRO
6
2.4k
AIとともに進化するエンジニアリング / Engineering-Evolving-with-AI_final.pdf
lycorptech_jp
PRO
0
110
生成AI時代 文字コードを学ぶ意義を見出せるか?
hrsued
1
610
Amazon Bedrockで実現する 新たな学習体験
kzkmaeda
2
610
Model Mondays S2E03: SLMs & Reasoning
nitya
0
110
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.8k
Making the Leap to Tech Lead
cromwellryan
134
9.4k
How GitHub (no longer) Works
holman
314
140k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
138
34k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
Facilitating Awesome Meetings
lara
54
6.4k
YesSQL, Process and Tooling at Scale
rocio
173
14k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Scaling GitHub
holman
459
140k
Visualization
eitanlees
146
16k
Transcript
初探 functional programming in JavaScript CypressKuo @前端組例會 2017/02/03 1
定義 一種程式設計的方法/概念 2
3
4
特色 ✣ Expression, no Statement ✣ First-class ✣ High order
function ✣ No side effect ✣ Referential transparency ✣ Pure Function 5
Expression, no Statement Expression Statement 6
First-class 函數與其他數據類型一樣,處於平等地位。 可以被賦值到其他變數, 也可以作為參數傳入到不同的函數中, 或者作為函數的回傳值。 7
8
9
10
High order function 滿足以下兩項其中之一的函數 ✣ 可以將函式當成參數傳入的函式 ✣ 可以將函式當成回傳值的函式 11
12
✣ .map() ✣ .filter() ✣ .reduce() ✣ .forEach() ✣ .some()
✣ .every() 常見的 High order function 13
No side effect 沒有與外部互動,產生與運算無關的其他結果。 ✣ 發送 http request ✣ 印出
console ✣ 取得使用者的 input 14
Referential transparency 不管外部環境如何,只要參數相同,函式執行的返回結果必定相同。 15
Pure Function 結合 no side effect 與 Referential transparency 一個
function 給予相同的參數, 永遠會回傳相同的返回值,並且沒有任何顯著的副作用 16
17
18
Function Composition ✣ Curry ✣ Compose 19
curry 將一個有 N 個參數的函數轉換成 N 個只有一個參數的函數 20
21
22
compose 把兩個以上的一個參數函數合併起來串聯多個組合成新的函數 23
24
25
優勢 ✣ 可讀性高 ✣ 可維護性高 ✣ 簡潔,開發快速 26
參考資料 http://blog.miniasp.com/post/2016/12/10/Functional-Programming-in-JavaScript.aspx?s=2 http://www.ruanyifeng.com/blog/2012/04/functional_programming.html http://www.slideshare.net/rockncoder/functional-programming-in-javascript-68835257 http://www.slideshare.net/ihower/fp-osdc2012v2 https://github.com/MostlyAdequate/mostly-adequate-guide http://ithelp.ithome.com.tw/articles/10186465 27