Class: Proc
Instance Method Summary collapse
Instance Method Details
#curry ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/funkr/compat/1.8.rb', line 3 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 |
#curry2 ⇒ Object
13 14 15 16 |
# File 'lib/funkr/compat/1.8.rb', line 13 def curry2 lambda{|a| lambda{|b| self.call(a,b)}} end |
#curry3 ⇒ Object
18 19 20 21 22 |
# File 'lib/funkr/compat/1.8.rb', line 18 def curry3 lambda{|a| lambda{|b| lambda{|c| self.call(a,b,c)}}} end |
#curry4 ⇒ Object
24 25 26 27 28 29 |
# File 'lib/funkr/compat/1.8.rb', line 24 def curry4 lambda{|a| lambda{|b| lambda{|c| lambda{|d| self.call(a,b,c,d)}}}} end |
#curry5 ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/funkr/compat/1.8.rb', line 31 def curry5 lambda{|a| lambda{|b| lambda{|c| lambda{|d| lambda{|e| self.call(a,b,c,d,e)}}}}} end |