Hi there, I pose this question & suggestion here instead the users list, I hope that
is fine in this context.
It is currently not possible to use "null" as a default argument for scalar
variables in function headers. It is, however, possible to use "NA". My
question: Is there a save procedure to use "!isnan(variable)" similar to
"exists(matrix)" for function headers? Currently, this seems not possible (or I
am making a mistake). E.g.:
<hansl>
scalar testNA = NA
scalar testNotNA = $pi
?testNA
?testNotNA
if isnan(testNA)
printf "NA, isnan(testNA) evals to %f",isnan(testNA)
else
printf "not NA, isnan(testNA) evals to %f",isnan(testNA)
endif
if isnan(testNotNA)
printf "NA, isnan(testNotNA) evals to %f",isnan(testNotNA)
else
printf "not NA, isnan(testNotNA) evals to %f",isnan(testNotNA)
endif
<\hansl>
This script produces wrong output. It (always) produces "0.000000?", adding this
"?" to the number and thus the statement always evaluates to "false"
(and !isnan(), too).
This goes in direction of svens suggestion: "idea for the exists()/nelem() situation
with lists" (following my confusion).
And then one other thing. In Python one can conveniently pass optional arguments via
"argument_label=argument_value", without having to care about the
sorting/completeness of the argument list. If such a thing was possible in hansl, that
would be very convenient!
Best
Frederik