German Rodriguez <[email protected]> asked,
> A mata question: Why is [...]
>
> . mata: strupper("a") >= "A"
> 0
>
> . mata: strupper("a") == "A"
> 1
Answer: There's a bug in Mata. This is rather embarrassing because, well,
watch this,
: "A" >= "A"
0
Obviously, the result should be 1 (meaning true). An examination of
Mata's source code reveals the that ">=" operator is being treated
the same as the ">" operator in the case of strings (and only in the
case of strings).
As I said, this is rather embarrassing. More than rather, in fact.
We will fix it.
German was discovered this when he wrote the code
scalar function isLetter(string scalar s)
{
S = strupper(s)
return(S >= "A" & S <= "Z")
}
To work around the bug, I sugest German change his code to read
scalar function isLetter(string scalar s)
{
S = strupper(s)
return(S > char(ascii("A")-1) & S <= "Z")
}
-- Bill
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/