Sha256: 6b18535efbbcf42a34e1783d27b5609f61f746e093ce38bf4d8838dd53398a85
Contents?: true
Size: 831 Bytes
Versions: 24
Compression:
Stored size: 831 Bytes
Contents
class Proc def curry case self.arity when 2 then curry2 when 3 then curry3 when 4 then curry4 when 5 then curry5 else raise "Can't curry more than 5 arguments" end end def curry2 lambda{|a| lambda{|b| self.call(a,b)}} end def curry3 lambda{|a| lambda{|b| lambda{|c| self.call(a,b,c)}}} end def curry4 lambda{|a| lambda{|b| lambda{|c| lambda{|d| self.call(a,b,c,d)}}}} end def curry5 lambda{|a| lambda{|b| lambda{|c| lambda{|d| lambda{|e| self.call(a,b,c,d,e)}}}}} end end class Object def define_singleton_method(name, &block) singleton = class << self; self end singleton.send(:define_method, name) do |*args| block.call(*args) end end end
Version data entries
24 entries across 24 versions & 1 rubygems