Class: Proc

Inherits:
Object show all
Defined in:
lib/funkr/compat/1.8.rb

Instance Method Summary collapse

Instance Method Details

#curryObject



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

#curry2Object



13
14
15
16
# File 'lib/funkr/compat/1.8.rb', line 13

def curry2
  lambda{|a|
    lambda{|b| self.call(a,b)}}
end

#curry3Object



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

#curry4Object



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

#curry5Object



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