Using a function as an input to a procedure?



I'm helping a colleague with some numerical work; one thing I need to do is
to create a small procedure which produces the difference between an
integral and its trapezoidal approximation; such as:

dt(f,a,b):=float(abs(integrate(f(s),s,a,b)-(f(a)+f(b))*(b-a)/2));

But this doesn't work; or at least, when I tried it earlier I got a "Too
many contexts" error message.  Is there an approved technique for writing a
procedure which uses functions as inputs?

Thanks,
Alasdair