public
Created

Kleyn: FP II

  • Download Gist
apply_math2.rb
Ruby
1 2 3 4 5 6 7 8 9 10
apply_math = lambda do |fn, a, b|
a.send(fn, b)
end
 
add = apply_math.curry.(:+)
subtract = apply_math.curry.(:-)
multiply = apply_math.curry.(:*)
divide = apply_math.curry.(:/)
 
add.(1, 2) # => 3

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.