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
#okark02 lambda_driver
Search
Yuuki Sumida
July 06, 2013
Programming
360
0
Share
#okark02 lambda_driver
Yuuki Sumida
July 06, 2013
More Decks by Yuuki Sumida
See All by Yuuki Sumida
stddev_popとstddev_sampの話 / stddev_pop and stddev_samp
razon
0
700
Monacaのビルド結果をSlackに通知したいマン[WIP] / Notify Monaca build results to Slack [WIP]
razon
0
480
ノベルティカンファレンス in 地方 / Novelty conference in local region
razon
0
860
おれたちのファイナルファンタジー勉強会 アンケート / Final Fantasy Survey
razon
1
280
フロントエンドわからなさすぎるのでVue CLIが吐き出すファイルを読む / Read the files generated by Vue CLI
razon
0
1.1k
今の飲みは次の飲みへ[完結編] / For the current drinking party to the next drinking party -final version-
razon
0
65
昔Reactで書いたコードをHyperappに移植した話 / Porting react to hyperapp
razon
0
280
今の飲みは次の飲みへ / For the current drinking party to the next drinking party
razon
0
65
大都会アワード2017 / Daitokai awards 2017
razon
0
950
Other Decks in Programming
See All in Programming
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.4k
Agentic AI: Evolution oder Revolution
mobilelarson
PRO
0
220
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
570
PHP 7.4でもOpenTelemetryゼロコード計装がしたい! / PHPerKaigi 2026
arthur1
1
450
AWS×クラウドネイティブソフトウェア設計 / AWS x Cloud-Native Software Design
nrslib
16
3.5k
RailsのValidatesをSwift Macrosで再現してみた
hokuron
0
140
車輪の再発明をしよう!PHP で実装して学ぶ、Web サーバーの仕組みと HTTP の正体
h1r0
2
470
生成 AI 時代のスナップショットテストってやつを見せてあげますよ(α版)
ojun9
0
320
「効かない!」依存性注入(DI)を活用したAPI Platformのエラーハンドリング奮闘記
mkmk884
0
280
ポーリング処理廃止によるイベント駆動アーキテクチャへの移行
seitarof
3
1.3k
Smarter Angular mit Transformers.js & Prompt API
christianliebel
PRO
1
110
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
310
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
500
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.4k
A Modern Web Designer's Workflow
chriscoyier
698
190k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
140
How to make the Groovebox
asonas
2
2.1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
150
The Curious Case for Waylosing
cassininazir
0
280
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
270
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
88
Abbi's Birthday
coloredviolet
2
6.1k
Transcript
lambda_driver.gemで加速する 関数型プログラミング 2013/07/06 岡山Ruby会議02
About me • もじゃ変 • @razon • 天領倉敷Scala/岡山Javaユーザ会 • #I社
• #多摩 送り中
About me • 2012/07
About me • 2013/06
About me
About me
None
None
日常でRubyを使うのに 足りないもの…
Functional-style Programming
None
※ちょっと補足(しとかないとマサカリが云々…) • 所謂「関数型言語」でなくても、ある程度関数 型言語っぽい書き方はできる • Ruby自体にある程度関数型プログラミングをサ ポートする機能がある – ラムダあるし –
カリー化できるし
How to use $ gem install lambda_driver require 'lambda_driver'
Feature • Proc/lambda/Symbol/Method extensions • Symbol extensions • Class extensions
• UnboundMethod extensions • Object extensions • 全部は紹介できないのでちょっとだけ…
Feature • Proc#call へのalias f = lambda{|x| x.to_s } f
< :foo # => "foo"
Feature • 関数合成 f = lambda{|x| x.to_s * 2 }
g = lambda{|y| y.length } h = f.compose g # => #<Proc:0x007ff78aa2ab2> h.(:hoge) # => "44" ( == f.call(g.call(:hoge)) ) f << g # => f.compose(g) f << g < :hoge # => "44" ( == f.call(g.call(:hoge)) ) f >> g # => g.compose(f) f >> g < :hoge # => "8" ( == g.call(f.call(:hoge)) )
Feature • 引数の入れ替え(Proc#flip) f = lambda{|x, y, z| [x, y,
z]} h = f.flip # => #<Proc:0x007ff78a942fa> h.call(:a).call(:b).call(:c) # => [:b, :a, :c] (== f.curry.call(:b).call(:a).call(:b)) h < :a < :b < :c # => [:b, :a, :c] (== f.curry.call(:b).call(:a).call(:b))
Feature • Object#revapply f = lambda{|x| x * 2 }
"foo".revapply(f) # => "fooffoo" (== f.call("foo") )
Trying “Fizz Buzz”
Trying “Fizz Buzz”
Trying “Fizz Buzz”
Trying “Fizz Buzz”
Appendix • pattern-match.gemというのもあります
まとめ • lambda_driver.gemかわいい • (まだ文化的に馴染みがないので)やり過ぎると たぶん周りの人に怒られる • だから皆関数型言語やれよ!! – 天領倉敷Scalaとか(9月以降やりたい)
– 岡山すごいHaskell読書会とか(次いつやんの?)
参考 • http://yuroyoro.github.io/lambda_driver/ • http://yuroyoro.hatenablog.com/entry/2013/03/27/190640
劇 終 ご清聴ありがとうございました