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
Church Numerals
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
HORINOUCHI Masato
March 26, 2018
Programming
51
0
Share
Church Numerals
社内LT大会 0x64物語Reboot #0x0C Lambda 資料
HORINOUCHI Masato
March 26, 2018
More Decks by HORINOUCHI Masato
See All by HORINOUCHI Masato
balenaCloud
thermes
0
85
CPS & CTO
thermes
0
250
FM synthesis
thermes
0
37
A440
thermes
0
64
Inside mml2wav.rb
thermes
0
87
Scheme Interpreter in Ruby
thermes
0
71
Clock / Timer
thermes
0
170
Hash Tree
thermes
0
79
POSIX Threads
thermes
0
57
Other Decks in Programming
See All in Programming
Kingdom of the Machine
yui_knk
2
1.5k
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
4
450
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
1k
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
420
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
300
ハーネスエンジニアリングとは?
kinopeee
13
6.9k
Back to the roots of date
jinroq
0
810
Agentic UI in the Frontend: Architectures with Open Standards @JAX 2026 in Mainz
manfredsteyer
PRO
0
110
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
3
340
[RubyKaigi 2026] Require Hooks
palkan
1
310
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
28
20k
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
500
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.1k
Odyssey Design
rkendrick25
PRO
2
610
Speed Design
sergeychernyshev
33
1.6k
Statistics for Hackers
jakevdp
799
230k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Site-Speed That Sticks
csswizardry
13
1.2k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
130
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
190
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
500
Transcript
Church Numerals 2018/03/26 0x64 Tales Reboot #0x0C Lambda Livesense Inc.
OB HORINOUCHI Masato
νϟʔνͱ • ࣗવΛϥϜμࣜͰදݱ͢Δํ๏ͷͻͱͭ • ؔͰΛද͍ͯ͠Δ
ϥϜμܭࢉ • ϥϜμܭࢉͰ 2 + 3 = 5 Λܭࢉͯ͠ΈΑ͏
νϟʔνͷఆٛ 0 := λf x. x 1 := λf x.
f x 2 := λf x. f (f x) 3 := λf x. f (f (f x)) ↓RubyͰॻ͘ͱ… cn_0 = lambda { |f, x| x } cn_1 = lambda { |f, x| f.call(x) } cn_2 = lambda { |f, x| f.call(f.call(x)) } cn_3 = lambda { |f, x| f.call(f.call(f.call(x))) }
ޙଓ SUCC := λn f x. f (n f x)
↓RubyͰॻ͘ͱ… succ = lambda { |n| lambda { |f, x| f.call(n.call(f, x)) } }
Ճࢉ PLUS := λm n f x. m f (n
f x) ↓RubyͰॻ͘ͱ… plus = lambda { |m, n| lambda { |f, x| m.call(f, (n.call(f, x))) } }
Rubyͷੈքͱม • ͩʔͬͱઆ໌͖͚ͯͨ͠Ͳɺ্هͰఆٛͨؔ͠νϟʔν (lambda)ͳͷͰ… • RubyωΠςΟϒͷදݱʹม͍ͯ͋͛ͨ͠ɻ def cn_to_i(cn) cn.call(lambda {
|x| x + 1 }, 0) end
σϞ
Next Step ܭࢉػϓϩάϥϜͷߏͱղऍ (௨শ SICP) MITͷೖίʔεͰ͏ܭࢉػՊֶͷ༏ ΕͨڭՊॻ ϋϧɾΤΠϒϧιϯ, δΣϦ ʔɾαεϚϯ,
δϡϦʔɾαεϚϯڞஶ( ాӳҰ༁)ʮܭࢉػϓϩάϥϜͷߏͱղ ऍ ୈೋ൛ʯ(ϐΞιϯɾΤσϡέʔγϣϯ 2000). දࢴͷຐज़ࢣΏ͑ʹͦ͏͍ΘΕ Δ. LISP/Schemeੈքͷయͷͻͱͭ.
·ͱΊ • SICP ಡॻձͰνϟʔνΛֶΜͩͱ͖ɺࢀՃऀશһṖͷײಈɻ • ΈΜͳ SICP ಡΜͰͶɻ • Ruby
ͷ Lambda .call ͠ͳ͍ͱ͍͚ͳ͍ͷͰɺಡΈॻ͖͠ ਏ͍…ɻ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠