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
340
#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
500
Monacaのビルド結果をSlackに通知したいマン[WIP] / Notify Monaca build results to Slack [WIP]
razon
0
360
ノベルティカンファレンス in 地方 / Novelty conference in local region
razon
0
630
おれたちのファイナルファンタジー勉強会 アンケート / Final Fantasy Survey
razon
1
170
フロントエンドわからなさすぎるのでVue CLIが吐き出すファイルを読む / Read the files generated by Vue CLI
razon
0
900
今の飲みは次の飲みへ[完結編] / For the current drinking party to the next drinking party -final version-
razon
0
44
昔Reactで書いたコードをHyperappに移植した話 / Porting react to hyperapp
razon
0
210
今の飲みは次の飲みへ / For the current drinking party to the next drinking party
razon
0
47
大都会アワード2017 / Daitokai awards 2017
razon
0
700
Other Decks in Programming
See All in Programming
DocC Tutorial と TCA におけるテスト機能の紹介
kalupas226
1
330
オブジェクト指向は必要なのか / Is object-oriented needed?
kishida
27
19k
自動テスト実行結果の目的を整理する / Organizing objectives of automated test results
twada
PRO
10
2.1k
The Future of C++ Interoperability: Insights from Porting a Game to Swift
teamhimeh
0
270
[スクリプト] Swiftの型推論を学ぼう
omochi
0
110
Cloud RunとCloud PubSubでサーバレスなデータ基盤2024 with Terraform / Cloud Run and PubSub with Terraform
shinyorke
7
1.9k
WinUI 3デモ - "CommunityToolkit.Mvvm"NuGetパッケージ編
andrewkeepcoding
0
130
とにかくHTTP3をライトニングに話す / Anyway, I'll talk to Lightning about HTTP3.
seike460
PRO
0
120
LLMチャットボットのアプリケーション設計Tips
os1ma
4
660
Creating Retro-Style Photos Using Swift
ski
1
340
Migrating to Signals: A Practical Workshop
manfredsteyer
PRO
0
280
Deep Dive 大規模システムアーキテクチャ/開発組織エンジニアリング / Deep Dive Large-Scale System Architecture, Development Organization Engineering
nrslib
15
2.9k
Featured
See All Featured
Become a Pro
speakerdeck
PRO
8
4.4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
19
1.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
350
18k
Happy Clients
brianwarren
91
6.3k
Embracing the Ebb and Flow
colly
78
4.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
12
1.4k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
39
4.3k
Designing for Performance
lara
601
67k
10 Git Anti Patterns You Should be Aware of
lemiorhan
644
57k
Debugging Ruby Performance
tmm1
68
11k
Teambox: Starting and Learning
jrom
126
8.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
272
12k
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
劇 終 ご清聴ありがとうございました