Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-03

function mapping to array?

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Xiangrong Fang

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