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
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
カリー化入門 / 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
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
260
Claspは野良GASの夢をみるか
takter00
0
210
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.8k
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
140
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
410
そのテスト、説明できますか?~LWテスト戦略FW~のご紹介
nakahara
0
160
TAKTでAI駆動開発の品質を設計する
j5ik2o
7
1.5k
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
150
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
940
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
790
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.3k
スマートグラスで並列バイブコーディング
hyshu
0
260
Featured
See All Featured
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
430
From π to Pie charts
rasagy
0
220
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
620
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
380
Building the Perfect Custom Keyboard
takai
2
800
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
250
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Technical Leadership for Architectural Decision Making
baasie
3
420
Paper Plane
katiecoart
PRO
1
52k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
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' 関数をカリー化する関数
ご清聴ありがとう ございました