From: "rits (First Last)" Date: 2012-12-02T04:54:14+09:00 Subject: [ruby-core:50461] [ruby-trunk - Feature #6284] Add composition for procs Issue #6284 has been updated by rits (First Last). proc composition is not commutative, so the operator should: 1. not imply commutativity 2. not conceal the order of application i.e. the operator should be visually asymmetrical with clear directionality e.g. <<, <<<, <- a << b << c = a(b(c(x))) right associative perhaps it also makes sense to have an opposite direction, left associative version: c >> b >> a = a(b(c(x))) ---------------------------------------- Feature #6284: Add composition for procs https://bugs.ruby-lang.org/issues/6284#change-34294 Author: pabloh (Pablo Herrero) Status: Feedback Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: next minor =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/