Martok schrieb am Sa., 21. Juli 2018, 17:12:
> Am 21.07.2018 um 02:08 schrieb Sven Barth via fpc-devel:
> > The main problem is that not all functions that would be eligible for
> your
> > approach are also declared as inline thus their node trees would not be
> stored
> > inside the PPU and
Am 21.07.2018 um 02:08 schrieb Sven Barth via fpc-devel:
> The main problem is that not all functions that would be eligible for your
> approach are also declared as inline thus their node trees would not be stored
> inside the PPU and thus you could not work with them.
I'm not sure I understand.
Sorry for that mess of a formatting on the code sample, Here is a much
nicer version!
function Binomial(n, r: Cardinal): Cardinal; pure;begin
if (r > n) then
Result := 0
else if (r = n) then
Result := 1 { Faster than calculating the factorials }
else
Result :=
An interesting read. If you can collapse an inline function into a single
assignment in most situations, then brilliant! Definitely keep that
optimisation in.
While there are many similarities and prerequisites between an inline function
and a pure function, and many simple mathematical
To follow up on this, even if you rewrote the function to use a
multiplicative formula (faster to compute overall):
function Binomial(n, r: Cardinal): Cardinal; pure;var c: Cardinal;
begin
for (r > n) then
Result := 0
else
begin
Result := 1;
if n r then