Am 24.04.2020 um 19:43 schrieb Riccardo (Jack) Lucchetti:
On Fri, 24 Apr 2020, Sven Schreiber wrote:
> Am 24.04.2020 um 18:33 schrieb Riccardo (Jack) Lucchetti:
>>
>> That said, conditional assignment is your friend. The sign of x can be
>> easily wriiten as
>>
>> s = x==0 ? 0 : (x>0 ? 1 : -1)
>>
> another example of the relativity of "easy" ;-)
Ok, let's say "concisely", then :)
Hm, why are more than 15
characters (stopped counting at some point...)
as concise as the 6 chars in "sgn(x)"?
> may have a point here. At least another candidate for the
'extra'
> package?
Such as
<hansl>
function matrix sign(matrix X)
return (X.=0) ? 0 : ((X.>0) ? 1 : -1)
end function
</hansl>
?
Yes; I hadn't even thought of the matrix case, but sure, why not? I know
in principle gretl accepts a 1x1 matrix "everywhere" a scalar is
expected, but are there exceptions to that "everywhere" that would be
important here?
thanks
sven