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)
> return a != floor(a) ? NA : a % 2 == 0
> end function
Uau !!
But I see that it is not needed an specific function, because for
example in an script where you already know it is always produced an
integer, you may easily use
scalar a = (b % 2==0 )
being a=1 if b is even and a=0 if b is odd ¿no?
Yes, that's right. If you're sure the input is OK you can just
use the modulo operator.
Allin