I'm trying to implement currying as per the the Little Schemer example eq?
given below. eq( test, testFor)
takes in a test condition and an atom and returns a function based on the passed function test
, which takes one argument to return a boolean.
Here is my code:
def eq( test, s)
Proc.new { |x| test(s,x)}
end
eqToCarrot = eq(Proc.new{|x,y| x==y},"carrot")
if eqToCarrot.call("carrot")
puts "Equal!"
end
The if condition is not executed. Can someone tell me why?