Re: [Gretl-users] isscalar

2012-11-10 Thread Sven Schreiber
On 11/09/2012 07:30 PM, Allin Cottrell wrote: > On Fri, 9 Nov 2012, Riccardo (Jack) Lucchetti wrote: > >> On Fri, 9 Nov 2012, Allin Cottrell wrote: >> >>> >>> if typeof(whatever) != "scalar" >>> ... >>> endif >> >> I like this. I do, too, but why not just use the word 'type'. The "of" part i

Re: [Gretl-users] isscalar

2012-11-09 Thread Ignacio Diaz-Emparanza
On 09/11/12 19:17, Allin Cottrell wrote: > ... The user-function can, however, be written more > tersely -- particularly if we take returning NA as sufficient > indication that the question is invalid: > > function scalar iseven (scalar a) > return a != floor(a) ? NA : a % 2 == 0 > end function

Re: [Gretl-users] isscalar

2012-11-09 Thread Jack
On Fri, 9 Nov 2012, Allin Cottrell wrote: > I've sometimes wondered if it would be worth trying to expose some sort of > "enum" system in gretl -- e.g. in this context NONE = 0, SCALAR = 1, SERIES = > 2 and so on. It would obviously be more intuitive to be able to do > > if typeof(whatever) == S

Re: [Gretl-users] isscalar

2012-11-09 Thread Jack
On Fri, 9 Nov 2012, Ignacio Diaz-Emparanza wrote: > Slightly related (but different) to this question: I needed frequently a > way to determine whether an integer is even or odd, and I finally wrote > this function: > > > function scalar iseven(scalar A) > if (A==floor(A)) > scalar A2

Re: [Gretl-users] isscalar

2012-11-09 Thread Jack
On Fri, 9 Nov 2012, Allin Cottrell wrote: > On Fri, 9 Nov 2012, Sven Schreiber wrote: > >> Am 09.11.2012 18:17, schrieb Allin Cottrell: >>> On Fri, 9 Nov 2012, Sven Schreiber wrote: I'm not saying I need it, but it isn't obvious to me why it is less useful in principle than for exam

Re: [Gretl-users] isscalar

2012-11-09 Thread Ignacio Diaz-Emparanza
Slightly related (but different) to this question: I needed frequently a way to determine whether an integer is even or odd, and I finally wrote this function: function scalar iseven(scalar A) if (A==floor(A)) scalar A2=floor(A/2) scalar A2b=A/2 scalar even = (A2

Re: [Gretl-users] isscalar

2012-11-09 Thread Sven Schreiber
Am 09.11.2012 18:17, schrieb Allin Cottrell: > On Fri, 9 Nov 2012, Sven Schreiber wrote: > >> >> I'm not saying I need it, but it isn't obvious to me why it is less >> useful in principle than for example 'isstring()'. Instead it seems to >> be a natural complement to the other 'is...()' function

Re: [Gretl-users] isscalar (was: functions mshape with variable elements and isscalar)

2012-11-09 Thread Sven Schreiber
Am 09.11.2012 15:30, schrieb Allin Cottrell: > On Fri, 9 Nov 2012, Pindar wrote: > >> The function 'isscalar' seems to be broken (and is only named on p. 148 in >> the Command Reference). > > Yes, it seems to be orphaned (and anyway does not seem to be > very useful). Let's get rid of it. > I'm n

Re: [Gretl-users] isscalar

2012-11-09 Thread Allin Cottrell
On Fri, 9 Nov 2012, Ignacio Diaz-Emparanza wrote: > On 09/11/12 19:17, Allin Cottrell wrote: >> ... The user-function can, however, be written more >> tersely -- particularly if we take returning NA as sufficient >> indication that the question is invalid: >> >> function scalar iseven (scalar a) >

Re: [Gretl-users] isscalar

2012-11-09 Thread Allin Cottrell
On Fri, 9 Nov 2012, Riccardo (Jack) Lucchetti wrote: > On Fri, 9 Nov 2012, Allin Cottrell wrote: > >> On Fri, 9 Nov 2012, Sven Schreiber wrote: >> >>> Am 09.11.2012 18:17, schrieb Allin Cottrell: On Fri, 9 Nov 2012, Sven Schreiber wrote: > > I'm not saying I need it, but it isn't ob

Re: [Gretl-users] isscalar

2012-11-09 Thread Allin Cottrell
On Fri, 9 Nov 2012, Ignacio Diaz-Emparanza wrote: > Slightly related (but different) to this question: I needed frequently a > way to determine whether an integer is even or odd, and I finally wrote > this function: > > > function scalar iseven(scalar A) > if (A==floor(A)) > scalar A2

Re: [Gretl-users] isscalar

2012-11-09 Thread Allin Cottrell
On Fri, 9 Nov 2012, Allin Cottrell wrote: > On Fri, 9 Nov 2012, Sven Schreiber wrote: > >> Am 09.11.2012 18:17, schrieb Allin Cottrell: >>> On Fri, 9 Nov 2012, Sven Schreiber wrote: I'm not saying I need it, but it isn't obvious to me why it is less useful in principle than for exa

Re: [Gretl-users] isscalar

2012-11-09 Thread Allin Cottrell
On Fri, 9 Nov 2012, Sven Schreiber wrote: > Am 09.11.2012 18:17, schrieb Allin Cottrell: >> On Fri, 9 Nov 2012, Sven Schreiber wrote: >>> >>> I'm not saying I need it, but it isn't obvious to me why it is less >>> useful in principle than for example 'isstring()'. Instead it seems to >>> be a natu

Re: [Gretl-users] isscalar (was: functions mshape with variable elements and isscalar)

2012-11-09 Thread Allin Cottrell
On Fri, 9 Nov 2012, Sven Schreiber wrote: > Am 09.11.2012 15:30, schrieb Allin Cottrell: >> On Fri, 9 Nov 2012, Pindar wrote: >>> The function 'isscalar' seems to be broken (and is only named on p. 148 in >>> the Command Reference). >> >> Yes, it seems to be orphaned (and anyway does not seem to b