From: "pabloh (Pablo Herrero)" Date: 2012-04-13T02:02:35+09:00 Subject: [ruby-core:44313] [ruby-trunk - Feature #6284] Add composition for procs Issue #6284 has been updated by pabloh (Pablo Herrero). trans (Thomas Sawyer) wrote: > Also, I think #+ is better. I saw facets has some similar feature that uses #* instead, maybe because it looks a bit closer to Haskell's composition syntax. Nevertheless, I still like #<< better, it feels that your are "connecting" the blocks together. ---------------------------------------- Feature #6284: Add composition for procs https://bugs.ruby-lang.org/issues/6284#change-25860 Author: pabloh (Pablo Herrero) Status: Open Priority: Normal Assignee: Category: Target version: 2.0.0 =begin It would be nice to be able to compose procs like functions in functional programming languages: to_camel = :capitalize.to_proc add_header = ->val {"Title: " + val} format_as_title = add_header << to_camel << :strip instead of: format_as_title = lambda {|val| "Title: " + val.strip.capitalize } It's pretty easy to implement in pure ruby: class Proc def << block proc { |*args| self.call( block.to_proc.call(*args) ) } end end =end -- http://bugs.ruby-lang.org/