Hi All,

In plain Pascal, I can do this:
	
type
   RealFunction = function(x: double): double;

function bisect(f: RealFunction; a, b: double): double;
begin
   if (abs(f(a)) < 0.001) then result := a
   else if (abs(f(b)) < 0.001) then result := b
   else begin
     // find the solution inside the interval
   end;
end;

So I can declare functions like these...

function f(x: double): double;
begin
   result := sin(x) - 0.5;
end;

function g(x: double): double;
begin
   result := x*x*x-10;
end;

... and call them this way:

var
   x1, x2: double;
begin
   x1 := bisect(f,0,pi/2);
   x2 := bisect(g,1,3);
   ...
end.

I have tried many ways to write this in Ruby but I failed to get it 
working as expected. Any hint?
Thank you.