Sha256: bf0c9fa76f16ce5c3c730df36dac56e54fac15e8e57409e85d3a6fd5f4947a61
Contents?: true
Size: 480 Bytes
Versions: 3
Compression:
Stored size: 480 Bytes
Contents
#-- # Thanks dave! #++ class Proc # Returns a new proc that is the functional # compostion of two procs, in order. # # require 'facet/proc/compose' # # a = lambda { |x| x + 4 } # b = lambda { |y| y / 2 } # # (a * b).call(4) #=> 6 # (b * a).call(4) #=> 4 # def compose(other) raise ArgumentError, "arity count mismatch" unless arity == other.arity #proc{ |*a| self.call(other.call(*a)) } proc{ |*a| self.call(*other.call(*a)) } end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facets-0.7.1 | lib/facet/proc/compose.rb |
facets-0.7.0 | lib/facet/proc/compose.rb |
facets-0.7.2 | lib/facet/proc/compose.rb |