-
-
Notifications
You must be signed in to change notification settings - Fork 379
Closed
Description
Again a somewhat weird title - but as always it comes with an example. The following errors, but I think it should actually be fine.
However, whether or not this errors is probably a decision that can be made arbitrarily.
transformed data {
vector[2] tmp = [1., 2.]';
// This is fine and prints `[]`
print(tmp[2:1]);
// This is not fine and errors with `vector[min_max] min indexing: accessing element out of range. index 3 out of range; expecting index to be between 1 and 2`
print(tmp[3:2]);
}For example, the equivalent in python apparently never errors (which I find weird):
[1, 2][1:0] # fine
[1, 2][2:1] # fine
[1, 2][1:2] # fine?!
[1, 2][2] # not fineThe equivalent in Julia (with the indices shifted due to Julia's 1-based indexing) does behave how I'd like Stan to behave (pretty please):
[1, 2][2:1] # fine, returns []
[1, 2][3:2] # fine, returns []
[1, 2][2:3] # not fine
[1, 2][3] # not fineMetadata
Metadata
Assignees
Labels
No labels