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
Nishimura Yuki
July 26, 2019
Programming
59
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
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
460
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
2
310
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
AI時代のUIはどこへ行く?その2!
yusukebe
19
6.6k
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.3k
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
270
CSC307 Lecture 17
javiergs
PRO
0
310
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
440
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
110
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
340
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
310
開発体験を左右するライブラリの API 設計 - GraphQL スキーマ構築ライブラリから考える #tskaigi
izumin5210
2
1.6k
Featured
See All Featured
Site-Speed That Sticks
csswizardry
13
1.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Building Applications with DynamoDB
mza
96
7.1k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
300
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
150
GitHub's CSS Performance
jonrohan
1033
470k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
400
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
160
Game over? The fight for quality and originality in the time of robots
wayneb77
1
190
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' 関数をカリー化する関数
ご清聴ありがとう ございました