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
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
34
Other Decks in Programming
See All in Programming
Dockerfile CMD for Node.js
grazie1999
0
150
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
220
VibeCodingからAgenticWorkflowへ
starfish719
0
960
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
580
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
530
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
400
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
240
React本体のコードリーディング
high_g_engineer
1
160
「つくるAI」だけではバグは見つからない ~テストに必要な「見つけるAI」を分離させる戦略~
mfunaki
0
200
実装をデザインガイドラインに追従させるための取り組み / 260731-dip-mosh-design-system
dachi023
0
7.9k
ALB ログから Trace を気合で繋げる技術
fohte
7
780
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
570
Featured
See All Featured
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
370
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
310
Google's AI Overviews - The New Search
badams
0
1.6k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.2k
Leo the Paperboy
mayatellez
8
2.2k
Building an army of robots
kneath
306
46k
The Curious Case for Waylosing
cassininazir
1
480
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
The SEO Collaboration Effect
kristinabergwall1
1
540
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
2
3.8k
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
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' 関数をカリー化する関数
ご清聴ありがとう ございました