Yuuki Sumida
July 06, 2013
330

# #okark02 lambda_driver

July 06, 2013

## Transcript

• #多摩 送り中

7. None
8. None

11. None

カリー化できるし

14. ### Feature • Proc/lambda/Symbol/Method extensions • Symbol extensions • Class extensions

• UnboundMethod extensions • Object extensions • 全部は紹介できないのでちょっとだけ…
15. ### Feature • Proc#call へのalias f = lambda{|x| x.to_s } f

< :foo # => "foo"
16. ### 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)) )
17. ### 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))
18. ### Feature • Object#revapply f = lambda{|x| x * 2 }

"foo".revapply(f) # => "fooffoo" (== f.call("foo") )