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
0
350
#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
660
Monacaのビルド結果をSlackに通知したいマン[WIP] / Notify Monaca build results to Slack [WIP]
razon
0
460
ノベルティカンファレンス in 地方 / Novelty conference in local region
razon
0
800
おれたちのファイナルファンタジー勉強会 アンケート / Final Fantasy Survey
razon
1
250
フロントエンドわからなさすぎるのでVue CLIが吐き出すファイルを読む / Read the files generated by Vue CLI
razon
0
1k
今の飲みは次の飲みへ[完結編] / For the current drinking party to the next drinking party -final version-
razon
0
57
昔Reactで書いたコードをHyperappに移植した話 / Porting react to hyperapp
razon
0
270
今の飲みは次の飲みへ / For the current drinking party to the next drinking party
razon
0
56
大都会アワード2017 / Daitokai awards 2017
razon
0
920
Other Decks in Programming
See All in Programming
AI 駆動開発におけるコミュニティと AWS CDK の価値
konokenj
5
300
O Que É e Como Funciona o PHP-FPM?
marcelgsantos
0
240
NixOS + Kubernetesで構築する自宅サーバーのすべて
ichi_h3
0
1.3k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
610
Software Architecture
hschwentner
6
2.4k
Kotlinで実装するCPU/GPU 「協調的」パフォーマンス管理
matuyuhi
0
100
pnpm に provenance のダウングレード を検出する PR を出してみた
ryo_manba
1
170
Claude Agent SDK を使ってみよう
hyshu
0
1.4k
理論と実務のギャップを超える
eycjur
0
200
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
410
CSC305 Lecture 10
javiergs
PRO
0
320
AI Agent 時代的開發者生存指南
eddie
4
2.2k
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
253
22k
Code Review Best Practice
trishagee
72
19k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
2.9k
Java REST API Framework Comparison - PWX 2021
mraible
34
8.9k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
GraphQLとの向き合い方2022年版
quramy
49
14k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
4 Signs Your Business is Dying
shpigford
186
22k
A Tale of Four Properties
chriscoyier
161
23k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.7k
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
劇 終 ご清聴ありがとうございました