stanc3
stanc3 copied to clipboard
Chained comparison
What does this Stan code do?
if (x < y < z) {
The natural (naïve?) reading is that the condition asks if x < y and y < z and that is indeed how Python or Julia would interpret it. (R considers it a syntax error.)
But Stan follows C/C++ convention where it reads (x < y) < z which is either 1 < z or 0 < z depending on whether or not x is less than y.
I think this should at least raise warning but preferably Stan could just implement comparison operators the same way Python and Julia do.