[Gretl-devel] Making the programming of user defined functions easier

Riccardo (Jack) Lucchetti r.lucchetti at univpm.it
Mon Oct 29 08:54:25 EDT 2007


On Mon, 29 Oct 2007, andreas.rosenblad at ltv.se wrote:

> 2. floor(): Round down to nearest integer. A complement to the current
> commands ceil(), that round up to nearest integer. As int() gives just the
> integer part, it gives the same value as floor() for positive values but
> the values for ceil() for negative values, thus floor() is needed for
> obtaining a round down to nearest integer for negative values. And floor()
> is a standrad matematical function that shouldn't be absent from gretl.

Agreed. Just commited it to CVS.

> 3. factorial()/permutation()/combination()
...

I'm personally against introducing functions (with the associated 
namespace pollution) for things that can easily be programmed 
at the user level just like you said. IMO, anyone for which factorial(n) 
is not obviously equivalent to gammafunc(n+1) shouldn't be writing 
functions in the first place. Of course, I'm fully open to be convinced 
of the contrary.

You may say that, by the same logic, one could define floor() as

f = (x>0) ? int(x) : -ceil(-x)

but, like you said, floor() is a standard function that should have been 
there right from the start.


Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche

r.lucchetti at univpm.it
http://www.econ.univpm.it/lucchetti


More information about the Gretl-devel mailing list