On Fri, 2 Dec 2016, Sven Schreiber wrote:
Am 02.12.2016 um 12:07 schrieb Artur T.:
> Let me come back to yesterdays issue. I am trying to run the following
> check whether variable "time" is in the list rxlist, or not. When time
> is not part of the list, I obtain the error message "error evaluating
> 'if'". However, I think gretl should simply return a zero in this case.
Yes it seems 'inlist()' has some problems. For example also 'eval inlist(a,
"s")' works (for 'a' as a defined list), although according to the
doc a
string as second argument wouldn't be allowed (should be an identifier or an
ID number).
The doc for inlist should be improved/updated, yes. But I think the
logic is correct (at least, arguably so).
If you'll permit me a silly analogy, consider these two questions:
Is Mr Frogbladder a member of parliament?
Is there a member of parliament named Mr Frogbladder?
The first version presupposes that a Mr Frogbladder exists in the
relevant context of discourse, while the second version does not. So
the first invites a response of "Ill-posed question" if there's no
Mr Frogbladder, while the second unambiguously gets an answer of No
in that case.
So now consider the following (where I've inverted the order to push
the error to the end):
<hansl>
nulldata 5
list L = const
eval inlist(L, const)
eval inlist(L, "frogbladder")
nulldata 5
list L = const
eval inlist(L, const)
eval inlist(L, frogbladder)
</hansl>
The answers are, respectively, 1, 0, 1 and <error> ("The symbol
'frogbladder' is undefined"). By putting the (putative) series-name
in quotes we're effectively asking the second of the original two
questions.
Artur's original question,
inlist(rxlist, rxlist.time)
is, it seems to me analogous to "Is Mr Frogbladder MP a member of
parliament?" (That is, is such-and-such a member of the list a
member of the list?) And it seems to me defensible that the question
fails. The right question is:
inlist(rxlist, "time")
As Sven remarked, this works but is not documented. I'll update the
doc.
Allin