[fpc-pascal]Problem using a function as a parameter
Mario Thaten
mario at thaten.de
Mon Feb 12 19:35:10 CET 2001
Hi everybody,
I've got a maybe simple question. Today I stumbled about a problem I
can't determine. The way I saw it in Turbo Pascal years ago, I tried
to implement a function as a parameter to another function. I'll send
some example code below.
fpc yells at it with an Error: Wrong amount of parameters specified.
Is this not implemented in fpc or am I stuck somewhere else?
Thanks for your hints in advance,
yours, Mario
Here's some example code to show my problem:
--8<--
type funcparam = function(x : real):real;
function f1(x : real):real;
begin
f1:=1/(x*x+1);
end;
function f2(x : real):real;
begin
f2:=x*x+1;
end;
function integral(a,e : real; f:funcparam):real;
begin
integral:=(f(a)+f(e))*0.5*(e-a);
end;
begin
writeln(integral(1,3,f1));
writeln(integral(1,3,f2));
end.
-->8--
--
.~. Mario Thaten (mario at thaten.de)
/V\
/( )\ "There are just 2 rules in life:
^ ^ Always be yourself, but never mind to change."
More information about the fpc-pascal
mailing list