Talk:Partial function application: Difference between revisions

Line 237:
 
<lang ruby>
def f(a, b, x)
proc {|a, b, x| a * x + b}
end
 
def f2(a, b, x)
lambda {|a, b, x| a * x + b}
end
 
def g
proc { |a| proc { |b| proc { |x| a * x + b } } }
end
 
def main
u = f2f.curry[7][9]
v = f2f.curry[7,9]
w = g[7][9]
puts [ [(1,2,3,4,..5]).map {|x| u[7][9][x]} \
, [(1,2,3,4,..5]).map {|x| v[x]} \
, [(1,2,3,4,..5]).map {|x| w[x]} ]
end
 
main
u = f2.curry[7][9]
v = f2.curry[7,9]
w = g[7][9]
puts [ [1,2,3,4,5].map {|x| u[x]} \
, [1,2,3,4,5].map {|x| v[x]} \
, [1,2,3,4,5].map {|x| w[x]} ]
</lang>
Anonymous user