Re: [fpc-pascal] function mapping to array?

2014-03-28 Thread Jonas Maebe

On 28/03/14 09:04, Xiangrong Fang wrote:

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


Write a wrapper function for them.


Jonas

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] function mapping to array?

2014-03-28 Thread 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
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal