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
カリー化入門 / currying
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Nishimura Yuki
July 26, 2019
Programming
58
0
Share
カリー化入門 / currying
あくあたん工房2019年7月部会のLTです
Nishimura Yuki
July 26, 2019
More Decks by Nishimura Yuki
See All by Nishimura Yuki
特に作りたいものがない人のためのプログラミング入門
ni5h1
0
110
モンスターマシンを起こすBotを作った話 / wake up bot
ni5h1
0
33
Other Decks in Programming
See All in Programming
Liberating Ruby's Parser from Lexer Hacks
ydah
2
2.7k
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
200
Cloudflare で始める Data Platform
ta93abe
0
170
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
780
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
410
過去のレビュー知見をSkillsで資産化した話
pkshadeck
PRO
1
2k
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
260
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
0
140
HTML-Aware ERB: The Path to Reactive Rendering @ RubyKaigi 2026, Hakodate, Japan
marcoroth
0
720
Firefoxにコントリビューションして得られた学び
ken7253
2
160
要はバランスからの卒業 #yumemi_grow
kajitack
0
170
20260514 - build with ai 2026 - build LINE Bot with Gemini CLI
line_developers_tw
PRO
0
450
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
Building AI with AI
inesmontani
PRO
1
1k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
200
30 Presentation Tips
portentint
PRO
1
290
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.6k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
360
YesSQL, Process and Tooling at Scale
rocio
174
15k
エンジニアに許された特別な時間の終わり
watany
106
240k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
120
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
Agile that works and the tools we love
rasmusluckow
331
21k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Transcript
カリー化入門 2019年あくあたん工房7月部会
そもそも カリー化って何?
カリー化 (currying, カリー化された =curried) とは、複数の引数をとる関数 を、引数が「もとの関数の最初の引 数」で戻り値が「もとの関数の残りの 引数を取り結果を返す関数」であるよ うな関数にすること(あるいはその関 数のこと)である。
出典:ウィキペディア
つまり、
N個の引数をとる関数 一引数を取る関数のチェイン
具体例
𝑓: 𝑥 → 𝑦 関数が引数を一つのみとる つまり、 すでにカリー化されている 引数を1個とる関数の場合
𝑓: 𝑥, 𝑦 → 𝑧 ↓ 𝑔: 𝑥 → (ℎ:
𝑦 → 𝑧) 引数を2個とる関数の場合
𝑓: 𝑥, 𝑦, 𝑧 → 𝑢 ↓ 𝑔: 𝑥 →
(ℎ: 𝑦 → (𝑖: 𝑧 → 𝑢)) 引数を3個とる関数の場合
何が うれしいの?
具体例として, 2つの引数の合計を返す関数f(x, y) をmap関数に渡す場合を考える
カリー化 されていないとき
func f(x,y) int { return x + y } func
g(x) int { return f(1, x) } list2 = map(g, list1)
カリー化 されているとき
func f(x,y) int { return x + y } list2
= map(g(1), list1)
部分適用で よくね
できることは同じ
func f(x,y) int { return x + y } g
= partial(f, 1) list2 = map(g, list1)
おまけ Pythonでカリー化
>>> currying.f("a")("b")("c") 'abc' カリー化されてる関数
>>> currying.f("a")("b")("c") 'abc' 関数をカリー化する関数
ご清聴ありがとう ございました