Talk:Partial function application: Difference between revisions

Line 232:
w = g(7)(9) # non-idiomatic
print [map(u(7)(9), [1,2,3,4,5]), map(v, [1,2,3,4,5]), map(w, [1,2,3,4,5])]
</lang>
 
Not entirely-correct Ruby 1.9 implementation:
 
<lang ruby>
def f(a, b, x)
a * x + b
end
 
def f2
lambda {|a, b, x| a * x + b}
end
 
def g
proc { |a| proc { |b| proc { |x| a * x + b } } }
end
 
u = f2.curry[7][9]
w = g.call(7).call(9)
puts [ [1,2,3,4,5].map {|x| u[x]} \
, [1,2,3,4,5].map {|x| w.call x} ]
</lang>
Anonymous user