Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
#okark02 lambda_driver
Search
Yuuki Sumida
July 06, 2013
Programming
380
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
#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
740
Monacaのビルド結果をSlackに通知したいマン[WIP] / Notify Monaca build results to Slack [WIP]
razon
0
490
ノベルティカンファレンス in 地方 / Novelty conference in local region
razon
0
910
おれたちのファイナルファンタジー勉強会 アンケート / Final Fantasy Survey
razon
1
300
フロントエンドわからなさすぎるので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
82
昔Reactで書いたコードをHyperappに移植した話 / Porting react to hyperapp
razon
0
300
今の飲みは次の飲みへ / For the current drinking party to the next drinking party
razon
0
77
大都会アワード2017 / Daitokai awards 2017
razon
0
970
Other Decks in Programming
See All in Programming
Verilogで学ぶCPU自作入門.pdf
uyuki234
7
3.9k
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
730
AWSに止められる覚悟してますか?
morizo_1984
2
490
mrbgem 三角測量 開発
ogom
0
150
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
510
wkhtmltopdfの次どうするか問題2026
willnet
2
1.8k
Agents on Rails - Rails at Scale 2026
irinanazarova
0
300
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
100
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
260
アクセシビリティから考える情報設計
high_g_engineer
0
430
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
160
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
220
Featured
See All Featured
Producing Creativity
orderedlist
PRO
348
41k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
450
Paper Plane
katiecoart
PRO
4
53k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
560
Utilizing Notion as your number one productivity tool
mfonobong
4
600
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
The Cult of Friendly URLs
andyhume
79
7k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
560
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
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
劇 終 ご清聴ありがとうございました