[fpc-pascal] function mapping to array?

Xiangrong Fang xrfang at gmail.com
Fri Mar 28 09:04:43 CET 2014


Hi All,

Is the following possible:

type
  TFunc=function(x: Double): Double;

procedure apply(f: TFunc; var x: array of Double);
var
  i: Integer;
begin
  for i := 0 to Length(x) - 1 do x[i] := f(x[i]);
end;

apply(@sqrt, x); <-- how can I apply() to built-in functions?

Thanks!

Xiangrong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140328/fd2daba9/attachment.html>


More information about the fpc-pascal mailing list