From: "alexeymuranov (Alexey Muranov)" Date: 2012-11-10T01:25:09+09:00 Subject: [ruby-core:49169] [ruby-trunk - Feature #6284] Add composition for procs Issue #6284 has been updated by alexeymuranov (Alexey Muranov). =begin I think that the meaning of (({#<-})) would not be symmetric with the meaning of (({#->})). Also, in mathematics, arrows are more like relations than operations. When used to describe functions, usually function arguments go to the arrow's tail, function values to the arrow's head, and function's name, for example, goes on top of the arrow. (In this sense Ruby's lambda syntax would look to me more natural in the form (({f = (a,b)->{ a + b }})) instead of (({f = ->(a,b){ a + b }})).) The main drawback of #* in my opinion is that is does not specify the direction of composition ((f*g)(x) is f(g(x)) or g(f(x))?), but since in Ruby function arguments are written on the right ((({f(g(x))}))), i think it can be assumed that the inner function is on the right and the outer is on the left. =end ---------------------------------------- Feature #6284: Add composition for procs https://bugs.ruby-lang.org/issues/6284#change-32721 Author: pabloh (Pablo Herrero) Status: Feedback Priority: Normal Assignee: matz (Yukihiro Matsumoto) 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/