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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yuuki Sumida
July 06, 2013
Programming
0
360
#okark02 lambda_driver
Yuuki Sumida
July 06, 2013
Tweet
Share
More Decks by Yuuki Sumida
See All by Yuuki Sumida
stddev_popとstddev_sampの話 / stddev_pop and stddev_samp
razon
0
680
Monacaのビルド結果をSlackに通知したいマン[WIP] / Notify Monaca build results to Slack [WIP]
razon
0
470
ノベルティカンファレンス in 地方 / Novelty conference in local region
razon
0
840
おれたちのファイナルファンタジー勉強会 アンケート / Final Fantasy Survey
razon
1
270
フロントエンドわからなさすぎるので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
60
昔Reactで書いたコードをHyperappに移植した話 / Porting react to hyperapp
razon
0
280
今の飲みは次の飲みへ / For the current drinking party to the next drinking party
razon
0
61
大都会アワード2017 / Daitokai awards 2017
razon
0
940
Other Decks in Programming
See All in Programming
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
170
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2.1k
Architectural Extensions
denyspoltorak
0
280
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
4.3k
CSC307 Lecture 09
javiergs
PRO
1
830
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.5k
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
250
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
5
350
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
380
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
180
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.9k
ThorVG Viewer In VS Code
nors
0
770
Featured
See All Featured
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
120
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
300
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.8k
WCS-LA-2024
lcolladotor
0
450
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
Designing Experiences People Love
moore
144
24k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
77
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
250
Ruling the World: When Life Gets Gamed
codingconduct
0
140
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
劇 終 ご清聴ありがとうございました